@@ -30,40 +30,40 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function wpinv_can_checkout() { |
| 33 | - $can_checkout = true; // Always true for now |
|
| 33 | + $can_checkout = true; // Always true for now |
|
| 34 | 34 | |
| 35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function wpinv_get_success_page_uri() { |
| 39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | - $page_id = absint( $page_id ); |
|
| 39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | + $page_id = absint( $page_id ); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_get_history_page_uri() { |
| 46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | - $page_id = absint( $page_id ); |
|
| 46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | + $page_id = absint( $page_id ); |
|
| 48 | 48 | |
| 49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function wpinv_is_success_page() { |
| 53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function wpinv_is_invoice_history_page() { |
| 60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | - $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | + $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function wpinv_send_to_success_page( $args = null ) { |
| 66 | - $redirect = wpinv_get_success_page_uri(); |
|
| 66 | + $redirect = wpinv_get_success_page_uri(); |
|
| 67 | 67 | |
| 68 | 68 | if ( !empty( $args ) ) { |
| 69 | 69 | // Check for backward compatibility |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | function wpinv_send_to_failed_page( $args = null ) { |
| 86 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
| 86 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
| 87 | 87 | |
| 88 | 88 | if ( !empty( $args ) ) { |
| 89 | 89 | // Check for backward compatibility |
@@ -103,72 +103,72 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | function wpinv_get_checkout_uri( $args = array() ) { |
| 106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 106 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 107 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 108 | 108 | |
| 109 | - if ( !empty( $args ) ) { |
|
| 110 | - // Check for backward compatibility |
|
| 111 | - if ( is_string( $args ) ) |
|
| 112 | - $args = str_replace( '?', '', $args ); |
|
| 109 | + if ( !empty( $args ) ) { |
|
| 110 | + // Check for backward compatibility |
|
| 111 | + if ( is_string( $args ) ) |
|
| 112 | + $args = str_replace( '?', '', $args ); |
|
| 113 | 113 | |
| 114 | - $args = wp_parse_args( $args ); |
|
| 114 | + $args = wp_parse_args( $args ); |
|
| 115 | 115 | |
| 116 | - $uri = add_query_arg( $args, $uri ); |
|
| 117 | - } |
|
| 116 | + $uri = add_query_arg( $args, $uri ); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 119 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 120 | 120 | |
| 121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 121 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 122 | 122 | |
| 123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 125 | - } |
|
| 123 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 124 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 127 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | function wpinv_send_back_to_checkout( $args = array() ) { |
| 131 | - $redirect = wpinv_get_checkout_uri(); |
|
| 131 | + $redirect = wpinv_get_checkout_uri(); |
|
| 132 | 132 | |
| 133 | - if ( ! empty( $args ) ) { |
|
| 134 | - // Check for backward compatibility |
|
| 135 | - if ( is_string( $args ) ) |
|
| 136 | - $args = str_replace( '?', '', $args ); |
|
| 133 | + if ( ! empty( $args ) ) { |
|
| 134 | + // Check for backward compatibility |
|
| 135 | + if ( is_string( $args ) ) |
|
| 136 | + $args = str_replace( '?', '', $args ); |
|
| 137 | 137 | |
| 138 | - $args = wp_parse_args( $args ); |
|
| 138 | + $args = wp_parse_args( $args ); |
|
| 139 | 139 | |
| 140 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 141 | - } |
|
| 140 | + $redirect = add_query_arg( $args, $redirect ); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 144 | - exit; |
|
| 143 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 144 | + exit; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | function wpinv_get_success_page_url( $query_string = null ) { |
| 148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 149 | - $success_page = get_permalink( $success_page ); |
|
| 148 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 149 | + $success_page = get_permalink( $success_page ); |
|
| 150 | 150 | |
| 151 | - if ( $query_string ) |
|
| 152 | - $success_page .= $query_string; |
|
| 151 | + if ( $query_string ) |
|
| 152 | + $success_page .= $query_string; |
|
| 153 | 153 | |
| 154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 154 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
| 158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 158 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 159 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 160 | 160 | |
| 161 | - if ( $extras ) |
|
| 162 | - $uri .= $extras; |
|
| 161 | + if ( $extras ) |
|
| 162 | + $uri .= $extras; |
|
| 163 | 163 | |
| 164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 164 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function wpinv_is_failed_transaction_page() { |
| 168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
| 169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 168 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
| 169 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 170 | 170 | |
| 171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 171 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -67,8 +67,9 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | if ( !empty( $args ) ) { |
| 69 | 69 | // Check for backward compatibility |
| 70 | - if ( is_string( $args ) ) |
|
| 71 | - $args = str_replace( '?', '', $args ); |
|
| 70 | + if ( is_string( $args ) ) { |
|
| 71 | + $args = str_replace( '?', '', $args ); |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | $args = wp_parse_args( $args ); |
| 74 | 75 | |
@@ -87,8 +88,9 @@ discard block |
||
| 87 | 88 | |
| 88 | 89 | if ( !empty( $args ) ) { |
| 89 | 90 | // Check for backward compatibility |
| 90 | - if ( is_string( $args ) ) |
|
| 91 | - $args = str_replace( '?', '', $args ); |
|
| 91 | + if ( is_string( $args ) ) { |
|
| 92 | + $args = str_replace( '?', '', $args ); |
|
| 93 | + } |
|
| 92 | 94 | |
| 93 | 95 | $args = wp_parse_args( $args ); |
| 94 | 96 | |
@@ -108,8 +110,9 @@ discard block |
||
| 108 | 110 | |
| 109 | 111 | if ( !empty( $args ) ) { |
| 110 | 112 | // Check for backward compatibility |
| 111 | - if ( is_string( $args ) ) |
|
| 112 | - $args = str_replace( '?', '', $args ); |
|
| 113 | + if ( is_string( $args ) ) { |
|
| 114 | + $args = str_replace( '?', '', $args ); |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | $args = wp_parse_args( $args ); |
| 115 | 118 | |
@@ -132,8 +135,9 @@ discard block |
||
| 132 | 135 | |
| 133 | 136 | if ( ! empty( $args ) ) { |
| 134 | 137 | // Check for backward compatibility |
| 135 | - if ( is_string( $args ) ) |
|
| 136 | - $args = str_replace( '?', '', $args ); |
|
| 138 | + if ( is_string( $args ) ) { |
|
| 139 | + $args = str_replace( '?', '', $args ); |
|
| 140 | + } |
|
| 137 | 141 | |
| 138 | 142 | $args = wp_parse_args( $args ); |
| 139 | 143 | |
@@ -148,8 +152,9 @@ discard block |
||
| 148 | 152 | $success_page = wpinv_get_option( 'success_page', 0 ); |
| 149 | 153 | $success_page = get_permalink( $success_page ); |
| 150 | 154 | |
| 151 | - if ( $query_string ) |
|
| 152 | - $success_page .= $query_string; |
|
| 155 | + if ( $query_string ) { |
|
| 156 | + $success_page .= $query_string; |
|
| 157 | + } |
|
| 153 | 158 | |
| 154 | 159 | return apply_filters( 'wpinv_success_page_url', $success_page ); |
| 155 | 160 | } |
@@ -158,8 +163,9 @@ discard block |
||
| 158 | 163 | $uri = wpinv_get_option( 'failure_page', '' ); |
| 159 | 164 | $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
| 160 | 165 | |
| 161 | - if ( $extras ) |
|
| 162 | - $uri .= $extras; |
|
| 166 | + if ( $extras ) { |
|
| 167 | + $uri .= $extras; |
|
| 168 | + } |
|
| 163 | 169 | |
| 164 | 170 | return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
| 165 | 171 | } |
@@ -7,195 +7,195 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function wpinv_is_checkout() { |
| 15 | 15 | global $wp_query; |
| 16 | 16 | |
| 17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
| 18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
| 19 | - $is_checkout = is_page( wpinv_get_option( 'checkout_page' ) ); |
|
| 17 | + $is_object_set = isset($wp_query->queried_object); |
|
| 18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
| 19 | + $is_checkout = is_page(wpinv_get_option('checkout_page')); |
|
| 20 | 20 | |
| 21 | - if ( !$is_object_set ) { |
|
| 22 | - unset( $wp_query->queried_object ); |
|
| 21 | + if (!$is_object_set) { |
|
| 22 | + unset($wp_query->queried_object); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if ( !$is_object_id_set ) { |
|
| 26 | - unset( $wp_query->queried_object_id ); |
|
| 25 | + if (!$is_object_id_set) { |
|
| 26 | + unset($wp_query->queried_object_id); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
| 29 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function wpinv_can_checkout() { |
| 33 | 33 | $can_checkout = true; // Always true for now |
| 34 | 34 | |
| 35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 35 | + return (bool)apply_filters('wpinv_can_checkout', $can_checkout); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function wpinv_get_success_page_uri() { |
| 39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | - $page_id = absint( $page_id ); |
|
| 39 | + $page_id = wpinv_get_option('success_page', 0); |
|
| 40 | + $page_id = absint($page_id); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 42 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_get_history_page_uri() { |
| 46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | - $page_id = absint( $page_id ); |
|
| 46 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
| 47 | + $page_id = absint($page_id); |
|
| 48 | 48 | |
| 49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 49 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function wpinv_is_success_page() { |
| 53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 53 | + $is_success_page = wpinv_get_option('success_page', false); |
|
| 54 | + $is_success_page = isset($is_success_page) ? is_page($is_success_page) : false; |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 56 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function wpinv_is_invoice_history_page() { |
| 60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | - $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 60 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
| 61 | + $ret = $ret ? is_page($ret) : false; |
|
| 62 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -function wpinv_send_to_success_page( $args = null ) { |
|
| 65 | +function wpinv_send_to_success_page($args = null) { |
|
| 66 | 66 | $redirect = wpinv_get_success_page_uri(); |
| 67 | 67 | |
| 68 | - if ( !empty( $args ) ) { |
|
| 68 | + if (!empty($args)) { |
|
| 69 | 69 | // Check for backward compatibility |
| 70 | - if ( is_string( $args ) ) |
|
| 71 | - $args = str_replace( '?', '', $args ); |
|
| 70 | + if (is_string($args)) |
|
| 71 | + $args = str_replace('?', '', $args); |
|
| 72 | 72 | |
| 73 | - $args = wp_parse_args( $args ); |
|
| 73 | + $args = wp_parse_args($args); |
|
| 74 | 74 | |
| 75 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 75 | + $redirect = add_query_arg($args, $redirect); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 78 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 79 | 79 | |
| 80 | - $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args ); |
|
| 81 | - wp_redirect( $redirect ); |
|
| 80 | + $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args); |
|
| 81 | + wp_redirect($redirect); |
|
| 82 | 82 | exit; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
| 85 | +function wpinv_send_to_failed_page($args = null) { |
|
| 86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
| 87 | 87 | |
| 88 | - if ( !empty( $args ) ) { |
|
| 88 | + if (!empty($args)) { |
|
| 89 | 89 | // Check for backward compatibility |
| 90 | - if ( is_string( $args ) ) |
|
| 91 | - $args = str_replace( '?', '', $args ); |
|
| 90 | + if (is_string($args)) |
|
| 91 | + $args = str_replace('?', '', $args); |
|
| 92 | 92 | |
| 93 | - $args = wp_parse_args( $args ); |
|
| 93 | + $args = wp_parse_args($args); |
|
| 94 | 94 | |
| 95 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 95 | + $redirect = add_query_arg($args, $redirect); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 99 | 99 | |
| 100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
| 101 | - wp_redirect( $redirect ); |
|
| 100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
| 101 | + wp_redirect($redirect); |
|
| 102 | 102 | exit; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
| 106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 105 | +function wpinv_get_checkout_uri($args = array()) { |
|
| 106 | + $uri = wpinv_get_option('checkout_page', false); |
|
| 107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
| 108 | 108 | |
| 109 | - if ( !empty( $args ) ) { |
|
| 109 | + if (!empty($args)) { |
|
| 110 | 110 | // Check for backward compatibility |
| 111 | - if ( is_string( $args ) ) |
|
| 112 | - $args = str_replace( '?', '', $args ); |
|
| 111 | + if (is_string($args)) |
|
| 112 | + $args = str_replace('?', '', $args); |
|
| 113 | 113 | |
| 114 | - $args = wp_parse_args( $args ); |
|
| 114 | + $args = wp_parse_args($args); |
|
| 115 | 115 | |
| 116 | - $uri = add_query_arg( $args, $uri ); |
|
| 116 | + $uri = add_query_arg($args, $uri); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 120 | 120 | |
| 121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 122 | 122 | |
| 123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
| 124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -function wpinv_send_back_to_checkout( $args = array() ) { |
|
| 130 | +function wpinv_send_back_to_checkout($args = array()) { |
|
| 131 | 131 | $redirect = wpinv_get_checkout_uri(); |
| 132 | 132 | |
| 133 | - if ( ! empty( $args ) ) { |
|
| 133 | + if (!empty($args)) { |
|
| 134 | 134 | // Check for backward compatibility |
| 135 | - if ( is_string( $args ) ) |
|
| 136 | - $args = str_replace( '?', '', $args ); |
|
| 135 | + if (is_string($args)) |
|
| 136 | + $args = str_replace('?', '', $args); |
|
| 137 | 137 | |
| 138 | - $args = wp_parse_args( $args ); |
|
| 138 | + $args = wp_parse_args($args); |
|
| 139 | 139 | |
| 140 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 140 | + $redirect = add_query_arg($args, $redirect); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 143 | + wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args)); |
|
| 144 | 144 | exit; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
| 148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 149 | - $success_page = get_permalink( $success_page ); |
|
| 147 | +function wpinv_get_success_page_url($query_string = null) { |
|
| 148 | + $success_page = wpinv_get_option('success_page', 0); |
|
| 149 | + $success_page = get_permalink($success_page); |
|
| 150 | 150 | |
| 151 | - if ( $query_string ) |
|
| 151 | + if ($query_string) |
|
| 152 | 152 | $success_page .= $query_string; |
| 153 | 153 | |
| 154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 154 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
| 158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 157 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
| 158 | + $uri = wpinv_get_option('failure_page', ''); |
|
| 159 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
| 160 | 160 | |
| 161 | - if ( $extras ) |
|
| 161 | + if ($extras) |
|
| 162 | 162 | $uri .= $extras; |
| 163 | 163 | |
| 164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 164 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function wpinv_is_failed_transaction_page() { |
| 168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
| 169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 168 | + $ret = wpinv_get_option('failure_page', false); |
|
| 169 | + $ret = isset($ret) ? is_page($ret) : false; |
|
| 170 | 170 | |
| 171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 171 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | -function wpinv_transaction_query( $type = 'start' ) { |
|
| 174 | +function wpinv_transaction_query($type = 'start') { |
|
| 175 | 175 | global $wpdb; |
| 176 | 176 | |
| 177 | 177 | $wpdb->hide_errors(); |
| 178 | 178 | |
| 179 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
| 180 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
| 179 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
| 180 | + define('WPINV_USE_TRANSACTIONS', true); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
| 184 | - switch ( $type ) { |
|
| 183 | + if (WPINV_USE_TRANSACTIONS) { |
|
| 184 | + switch ($type) { |
|
| 185 | 185 | case 'commit' : |
| 186 | - $wpdb->query( 'COMMIT' ); |
|
| 186 | + $wpdb->query('COMMIT'); |
|
| 187 | 187 | break; |
| 188 | 188 | case 'rollback' : |
| 189 | - $wpdb->query( 'ROLLBACK' ); |
|
| 189 | + $wpdb->query('ROLLBACK'); |
|
| 190 | 190 | break; |
| 191 | 191 | default : |
| 192 | - $wpdb->query( 'START TRANSACTION' ); |
|
| 192 | + $wpdb->query('START TRANSACTION'); |
|
| 193 | 193 | break; |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | -function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) { |
|
| 198 | +function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) { |
|
| 199 | 199 | $default_args = array( |
| 200 | 200 | 'status' => '', |
| 201 | 201 | 'user_id' => null, |
@@ -205,72 +205,72 @@ discard block |
||
| 205 | 205 | 'parent' => 0 |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | - $args = wp_parse_args( $args, $default_args ); |
|
| 208 | + $args = wp_parse_args($args, $default_args); |
|
| 209 | 209 | $invoice_data = array(); |
| 210 | 210 | |
| 211 | - if ( $args['invoice_id'] > 0 ) { |
|
| 212 | - $updating = true; |
|
| 211 | + if ($args['invoice_id'] > 0) { |
|
| 212 | + $updating = true; |
|
| 213 | 213 | $invoice_data['post_type'] = 'wpi_invoice'; |
| 214 | 214 | $invoice_data['ID'] = $args['invoice_id']; |
| 215 | 215 | } else { |
| 216 | 216 | $updating = false; |
| 217 | 217 | $invoice_data['post_type'] = 'wpi_invoice'; |
| 218 | - $invoice_data['post_status'] = apply_filters( 'wpinv_default_invoice_status', 'pending' ); |
|
| 218 | + $invoice_data['post_status'] = apply_filters('wpinv_default_invoice_status', 'pending'); |
|
| 219 | 219 | $invoice_data['ping_status'] = 'closed'; |
| 220 | - $invoice_data['post_author'] = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
| 221 | - $invoice_data['post_title'] = wpinv_format_invoice_number( '0' ); |
|
| 222 | - $invoice_data['post_parent'] = absint( $args['parent'] ); |
|
| 223 | - if ( !empty( $args['created_date'] ) ) { |
|
| 220 | + $invoice_data['post_author'] = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
| 221 | + $invoice_data['post_title'] = wpinv_format_invoice_number('0'); |
|
| 222 | + $invoice_data['post_parent'] = absint($args['parent']); |
|
| 223 | + if (!empty($args['created_date'])) { |
|
| 224 | 224 | $invoice_data['post_date'] = $args['created_date']; |
| 225 | - $invoice_data['post_date_gmt'] = get_gmt_from_date( $args['created_date'] ); |
|
| 225 | + $invoice_data['post_date_gmt'] = get_gmt_from_date($args['created_date']); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( $args['status'] ) { |
|
| 230 | - if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 231 | - return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) ); |
|
| 229 | + if ($args['status']) { |
|
| 230 | + if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) { |
|
| 231 | + return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status'])); |
|
| 232 | 232 | } |
| 233 | - $invoice_data['post_status'] = $args['status']; |
|
| 233 | + $invoice_data['post_status'] = $args['status']; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( ! is_null( $args['user_note'] ) ) { |
|
| 237 | - $invoice_data['post_excerpt'] = $args['user_note']; |
|
| 236 | + if (!is_null($args['user_note'])) { |
|
| 237 | + $invoice_data['post_excerpt'] = $args['user_note']; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if ( $updating ) { |
|
| 241 | - $invoice_id = wp_update_post( $invoice_data, true ); |
|
| 240 | + if ($updating) { |
|
| 241 | + $invoice_id = wp_update_post($invoice_data, true); |
|
| 242 | 242 | } else { |
| 243 | - $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true ); |
|
| 243 | + $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( is_wp_error( $invoice_id ) ) { |
|
| 246 | + if (is_wp_error($invoice_id)) { |
|
| 247 | 247 | return $wp_error ? $invoice_id : 0; |
| 248 | 248 | } else { |
| 249 | - if ( !$updating ) { |
|
| 250 | - $invoice_number = wpinv_format_invoice_number( $invoice_id ); |
|
| 249 | + if (!$updating) { |
|
| 250 | + $invoice_number = wpinv_format_invoice_number($invoice_id); |
|
| 251 | 251 | |
| 252 | - $update = array( 'ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title( $invoice_number ) ); |
|
| 253 | - wp_update_post( $update ); |
|
| 252 | + $update = array('ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title($invoice_number)); |
|
| 253 | + wp_update_post($update); |
|
| 254 | 254 | |
| 255 | - update_post_meta( $invoice_id, '_wpinv_number', $invoice_number ); |
|
| 255 | + update_post_meta($invoice_id, '_wpinv_number', $invoice_number); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 260 | - |
|
| 261 | - if ( !$updating ) { |
|
| 262 | - update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) ); |
|
| 263 | - update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() ); |
|
| 264 | - update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) ); |
|
| 265 | - update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() ); |
|
| 266 | - update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() ); |
|
| 267 | - update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) ); |
|
| 259 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 260 | + |
|
| 261 | + if (!$updating) { |
|
| 262 | + update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_'))); |
|
| 263 | + update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency()); |
|
| 264 | + update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax')); |
|
| 265 | + update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip()); |
|
| 266 | + update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent()); |
|
| 267 | + update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via'])); |
|
| 268 | 268 | |
| 269 | 269 | // Add invoice note |
| 270 | - $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) ); |
|
| 270 | + $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status))); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION ); |
|
| 273 | + update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION); |
|
| 274 | 274 | |
| 275 | 275 | return $invoice; |
| 276 | 276 | } |
@@ -278,118 +278,118 @@ discard block |
||
| 278 | 278 | function wpinv_get_prefix() { |
| 279 | 279 | $invoice_prefix = 'INV-'; |
| 280 | 280 | |
| 281 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
| 281 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | function wpinv_get_business_logo() { |
| 285 | - $business_logo = wpinv_get_option( 'logo' ); |
|
| 286 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
| 285 | + $business_logo = wpinv_get_option('logo'); |
|
| 286 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | function wpinv_get_business_name() { |
| 290 | 290 | $business_name = wpinv_get_option('store_name'); |
| 291 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
| 291 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | function wpinv_get_blogname() { |
| 295 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
| 295 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | function wpinv_get_admin_email() { |
| 299 | - $admin_email = get_option( 'admin_email' ); |
|
| 300 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
| 299 | + $admin_email = get_option('admin_email'); |
|
| 300 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | function wpinv_get_business_website() { |
| 304 | - $business_website = home_url( '/' ); |
|
| 305 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
| 304 | + $business_website = home_url('/'); |
|
| 305 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
| 308 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
| 309 | 309 | $terms_text = ''; |
| 310 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
| 310 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | function wpinv_get_business_footer() { |
| 314 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
| 315 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
| 316 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
| 314 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
| 315 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
| 316 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | function wpinv_checkout_required_fields() { |
| 320 | 320 | $required_fields = array(); |
| 321 | 321 | |
| 322 | 322 | // Let payment gateways and other extensions determine if address fields should be required |
| 323 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
| 323 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
| 324 | 324 | |
| 325 | - if ( $require_billing_details ) { |
|
| 325 | + if ($require_billing_details) { |
|
| 326 | 326 | ///$required_fields['email'] = array( |
| 327 | 327 | ///'error_id' => 'invalid_email', |
| 328 | 328 | ///'error_message' => __( 'Please enter a valid email address', 'invoicing' ) |
| 329 | 329 | ///); |
| 330 | 330 | $required_fields['first_name'] = array( |
| 331 | 331 | 'error_id' => 'invalid_first_name', |
| 332 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
| 332 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
| 333 | 333 | ); |
| 334 | 334 | $required_fields['address'] = array( |
| 335 | 335 | 'error_id' => 'invalid_address', |
| 336 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
| 336 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
| 337 | 337 | ); |
| 338 | 338 | $required_fields['city'] = array( |
| 339 | 339 | 'error_id' => 'invalid_city', |
| 340 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
| 340 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
| 341 | 341 | ); |
| 342 | 342 | $required_fields['state'] = array( |
| 343 | 343 | 'error_id' => 'invalid_state', |
| 344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
| 344 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
| 345 | 345 | ); |
| 346 | 346 | $required_fields['country'] = array( |
| 347 | 347 | 'error_id' => 'invalid_country', |
| 348 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
| 348 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
| 349 | 349 | ); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
| 352 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | function wpinv_is_ssl_enforced() { |
| 356 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
| 357 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
| 356 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
| 357 | + return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | -function wpinv_user_can_print_invoice( $post ) { |
|
| 360 | +function wpinv_user_can_print_invoice($post) { |
|
| 361 | 361 | $allow = false; |
| 362 | 362 | |
| 363 | - if ( !( $user_id = get_current_user_id() ) ) { |
|
| 363 | + if (!($user_id = get_current_user_id())) { |
|
| 364 | 364 | return $allow; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( is_int( $post ) ) { |
|
| 368 | - $post = get_post( $post ); |
|
| 367 | + if (is_int($post)) { |
|
| 368 | + $post = get_post($post); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | // Allow to owner. |
| 372 | - if ( is_object( $post ) && !empty( $post->post_author ) && $post->post_author == $user_id ) { |
|
| 372 | + if (is_object($post) && !empty($post->post_author) && $post->post_author == $user_id) { |
|
| 373 | 373 | $allow = true; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Allow to admin user. |
| 377 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 377 | + if (current_user_can('manage_options')) { |
|
| 378 | 378 | $allow = true; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - return apply_filters( 'wpinv_can_print_invoice', $allow, $post ); |
|
| 381 | + return apply_filters('wpinv_can_print_invoice', $allow, $post); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | function wpinv_schedule_events() { |
| 385 | 385 | // hourly, daily and twicedaily |
| 386 | - if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) { |
|
| 387 | - wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' ); |
|
| 386 | + if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) { |
|
| 387 | + wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily'); |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | -add_action( 'wp', 'wpinv_schedule_events' ); |
|
| 390 | +add_action('wp', 'wpinv_schedule_events'); |
|
| 391 | 391 | |
| 392 | 392 | function wpinv_schedule_event_twicedaily() { |
| 393 | 393 | wpinv_email_payment_reminders(); |
| 394 | 394 | } |
| 395 | -add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' ); |
|
| 396 | 395 | \ No newline at end of file |
| 396 | +add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily'); |
|
| 397 | 397 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | 'wpinv_receipt' => __CLASS__ . '::receipt', |
| 15 | 15 | ); |
| 16 | 16 | |
| 17 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
| 18 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
| 17 | + foreach ($shortcodes as $shortcode => $function) { |
|
| 18 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
| 21 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public static function shortcode_wrapper( |
@@ -32,24 +32,24 @@ discard block |
||
| 32 | 32 | ) { |
| 33 | 33 | ob_start(); |
| 34 | 34 | |
| 35 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
| 36 | - call_user_func( $function, $atts ); |
|
| 37 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
| 35 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
| 36 | + call_user_func($function, $atts); |
|
| 37 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
| 38 | 38 | |
| 39 | 39 | return ob_get_clean(); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public static function checkout( $atts = array(), $content = null ) { |
|
| 43 | - return wpinv_checkout_form( $atts, $content ); |
|
| 42 | + public static function checkout($atts = array(), $content = null) { |
|
| 43 | + return wpinv_checkout_form($atts, $content); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public static function messages( $atts, $content = null ) { |
|
| 46 | + public static function messages($atts, $content = null) { |
|
| 47 | 47 | ob_start(); |
| 48 | 48 | wpinv_print_errors(); |
| 49 | 49 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public static function history( $atts, $content = null ) { |
|
| 52 | + public static function history($atts, $content = null) { |
|
| 53 | 53 | ob_start(); |
| 54 | 54 | |
| 55 | 55 | wpinv_user_invoices(); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | return ob_get_clean(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public static function receipt( $atts, $content = null ) { |
|
| 61 | - return wpinv_payment_receipt( $atts, $content ); |
|
| 60 | + public static function receipt($atts, $content = null) { |
|
| 61 | + return wpinv_payment_receipt($atts, $content); |
|
| 62 | 62 | } |
| 63 | 63 | } |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Billing_Details { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $user_ID; |
| 10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 11 | + $invoice = new WPInv_Invoice($post_id); |
|
| 12 | 12 | ?> |
| 13 | 13 | <div class="gdmbx2-wrap form-table"> |
| 14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
| 15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
| 16 | 16 | <div class="gdmbx-th"> |
| 17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
| 17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
| 18 | 18 | </div> |
| 19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
| 20 | - <?php wpinv_dropdown_users( array( |
|
| 20 | + <?php wpinv_dropdown_users(array( |
|
| 21 | 21 | 'name' => 'post_author_override', |
| 22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
| 23 | 23 | 'include_selected' => true, |
| 24 | 24 | 'show' => 'user_email', |
| 25 | 25 | 'orderby' => 'user_email', |
| 26 | 26 | 'class' => 'gdmbx2-text-large' |
| 27 | - ) ); ?> |
|
| 27 | + )); ?> |
|
| 28 | 28 | </div> |
| 29 | 29 | </div> |
| 30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
| 31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
| 31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
| 32 | 32 | </div> |
| 33 | 33 | <div class="gdmbx-td"> |
| 34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
| 39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
| 39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
| 40 | 40 | </div> |
| 41 | 41 | <div class="gdmbx-td"> |
| 42 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
| 43 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
| 44 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
| 42 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
| 43 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
| 44 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
| 45 | 45 | </div> |
| 46 | 46 | </div> |
| 47 | 47 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
| 48 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 48 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 49 | 49 | <div class="gdmbx-td"> |
| 50 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" required="required" /> |
|
| 50 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" required="required" /> |
|
| 51 | 51 | </div> |
| 52 | 52 | </div> |
| 53 | 53 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
| 54 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
| 54 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
| 55 | 55 | <div class="gdmbx-td"> |
| 56 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
| 56 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
| 57 | 57 | </div> |
| 58 | 58 | </div> |
| 59 | 59 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
| 60 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
| 60 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
| 61 | 61 | <div class="gdmbx-td"> |
| 62 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
| 62 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
| 63 | 63 | </div> |
| 64 | 64 | </div> |
| 65 | 65 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
| 66 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
| 66 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
| 67 | 67 | <div class="gdmbx-td"> |
| 68 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
| 68 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
| 69 | 69 | </div> |
| 70 | 70 | </div> |
| 71 | 71 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
| 72 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 72 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 73 | 73 | <div class="gdmbx-td"> |
| 74 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" required="required" /> |
|
| 74 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" required="required" /> |
|
| 75 | 75 | </div> |
| 76 | 76 | </div> |
| 77 | 77 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
| 78 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 78 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 79 | 79 | <div class="gdmbx-td"> |
| 80 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" required="required" /> |
|
| 80 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" required="required" /> |
|
| 81 | 81 | </div> |
| 82 | 82 | </div> |
| 83 | 83 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
| 84 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="required">*</span> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 84 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="required">*</span> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 85 | 85 | <div class="gdmbx-td"> |
| 86 | 86 | <?php |
| 87 | - echo wpinv_html_select( array( |
|
| 88 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
| 87 | + echo wpinv_html_select(array( |
|
| 88 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
| 89 | 89 | 'name' => 'wpinv_country', |
| 90 | 90 | 'id' => 'wpinv_country', |
| 91 | 91 | 'selected' => $invoice->country, |
@@ -93,20 +93,20 @@ discard block |
||
| 93 | 93 | 'show_option_none' => false, |
| 94 | 94 | 'class' => 'gdmbx2-text-large', |
| 95 | 95 | 'chosen' => false, |
| 96 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 96 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 97 | 97 | 'required' => true, |
| 98 | - ) ); |
|
| 98 | + )); |
|
| 99 | 99 | ?> |
| 100 | 100 | </div> |
| 101 | 101 | </div> |
| 102 | 102 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
| 103 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 103 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 104 | 104 | <div class="gdmbx-td"> |
| 105 | 105 | <?php |
| 106 | - $states = wpinv_get_country_states( $invoice->country ); |
|
| 107 | - if( !empty( $states ) ) { |
|
| 108 | - echo wpinv_html_select( array( |
|
| 109 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
| 106 | + $states = wpinv_get_country_states($invoice->country); |
|
| 107 | + if (!empty($states)) { |
|
| 108 | + echo wpinv_html_select(array( |
|
| 109 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
| 110 | 110 | 'name' => 'wpinv_state', |
| 111 | 111 | 'id' => 'wpinv_state', |
| 112 | 112 | 'selected' => $invoice->state, |
@@ -114,44 +114,44 @@ discard block |
||
| 114 | 114 | 'show_option_none' => false, |
| 115 | 115 | 'class' => 'gdmbx2-text-large', |
| 116 | 116 | 'chosen' => false, |
| 117 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 117 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 118 | 118 | 'required' => true, |
| 119 | - ) ); |
|
| 119 | + )); |
|
| 120 | 120 | } else { |
| 121 | - echo wpinv_html_text( array( |
|
| 121 | + echo wpinv_html_text(array( |
|
| 122 | 122 | 'name' => 'wpinv_state', |
| 123 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
| 123 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
| 124 | 124 | 'id' => 'wpinv_state', |
| 125 | 125 | 'class' => 'gdmbx2-text-large', |
| 126 | 126 | 'required' => true, |
| 127 | - ) ); |
|
| 127 | + )); |
|
| 128 | 128 | } |
| 129 | 129 | ?> |
| 130 | 130 | </div> |
| 131 | 131 | </div> |
| 132 | 132 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
| 133 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
| 133 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
| 134 | 134 | <div class="gdmbx-td"> |
| 135 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
| 135 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
| 136 | 136 | </div> |
| 137 | 137 | </div> |
| 138 | 138 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
| 139 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?> <?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="required">*</span>'; } ?></label></div> |
|
| 139 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?> <?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="required">*</span>'; } ?></label></div> |
|
| 140 | 140 | <div class="gdmbx-td"> |
| 141 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" <?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo 'required="required"'; } ?> /> |
|
| 141 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" <?php if (wpinv_get_option('phone_mandatory')) { echo 'required="required"'; } ?> /> |
|
| 142 | 142 | </div> |
| 143 | 143 | </div> |
| 144 | 144 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
| 145 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
| 146 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 145 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
| 146 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 147 | 147 | <?php } ?></label></div> |
| 148 | 148 | <div class="gdmbx-td"> |
| 149 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
| 149 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
| 150 | 150 | </div> |
| 151 | 151 | </div> |
| 152 | 152 | </div> |
| 153 | 153 | </div> |
| 154 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
| 154 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
| 155 | 155 | <?php |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -1,39 +1,39 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Notes { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $post; |
| 10 | 10 | |
| 11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
| 11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
| 12 | 12 | |
| 13 | 13 | echo '<ul class="invoice_notes">'; |
| 14 | 14 | |
| 15 | - if ( $notes ) { |
|
| 16 | - foreach( $notes as $note ) { |
|
| 17 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 15 | + if ($notes) { |
|
| 16 | + foreach ($notes as $note) { |
|
| 17 | + wpinv_get_invoice_note_line_item($note); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | } else { |
| 21 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
| 21 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | echo '</ul>'; |
| 25 | 25 | ?> |
| 26 | 26 | <div class="add_note"> |
| 27 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
| 27 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
| 28 | 28 | <p> |
| 29 | 29 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
| 30 | 30 | </p> |
| 31 | 31 | <p> |
| 32 | 32 | <select name="invoice_note_type" id="invoice_note_type"> |
| 33 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
| 34 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
| 33 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
| 34 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
| 35 | 35 | </select> |
| 36 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
| 36 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
| 37 | 37 | </p> |
| 38 | 38 | </div> |
| 39 | 39 | <?php |
@@ -196,8 +196,9 @@ |
||
| 196 | 196 | foreach ( $types as $name => $type ) { |
| 197 | 197 | echo '<option value="' . esc_attr( $name ) . '"'; |
| 198 | 198 | |
| 199 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 200 | - selected( $name, $_GET['discount_type'] ); |
|
| 199 | + if ( isset( $_GET['discount_type'] ) ) { |
|
| 200 | + selected( $name, $_GET['discount_type'] ); |
|
| 201 | + } |
|
| 201 | 202 | |
| 202 | 203 | echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
| 203 | 204 | } |
@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -add_action( 'admin_menu', 'wpinv_add_options_link', 10 ); |
|
| 7 | +add_action('admin_menu', 'wpinv_add_options_link', 10); |
|
| 8 | 8 | function wpinv_add_options_link() { |
| 9 | 9 | global $menu; |
| 10 | 10 | |
| 11 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 12 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
| 11 | + if (current_user_can('manage_options')) { |
|
| 12 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
| 15 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
| 16 | 16 | |
| 17 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
| 17 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
| 18 | 18 | |
| 19 | - $wpi_settings_page = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), 'manage_options', 'wpinv-settings', 'wpinv_options_page' ); |
|
| 19 | + $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), 'manage_options', 'wpinv-settings', 'wpinv_options_page'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 ); |
|
| 22 | +add_action('admin_menu', 'wpinv_remove_admin_submenus', 999); |
|
| 23 | 23 | function wpinv_remove_admin_submenus() { |
| 24 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
| 24 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
| 28 | -function wpinv_discount_columns( $existing_columns ) { |
|
| 27 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
| 28 | +function wpinv_discount_columns($existing_columns) { |
|
| 29 | 29 | $columns = array(); |
| 30 | 30 | $columns['cb'] = $existing_columns['cb']; |
| 31 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
| 32 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
| 33 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
| 34 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
| 35 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
| 36 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
| 31 | + $columns['name'] = __('Name', 'invoicing'); |
|
| 32 | + $columns['code'] = __('Code', 'invoicing'); |
|
| 33 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
| 34 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
| 35 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
| 36 | + $columns['status'] = __('Status', 'invoicing'); |
|
| 37 | 37 | |
| 38 | 38 | return $columns; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
| 42 | -function wpinv_discount_custom_column( $column ) { |
|
| 41 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
| 42 | +function wpinv_discount_custom_column($column) { |
|
| 43 | 43 | global $post; |
| 44 | 44 | |
| 45 | 45 | $discount = $post; |
| 46 | 46 | |
| 47 | - switch ( $column ) { |
|
| 47 | + switch ($column) { |
|
| 48 | 48 | case 'name' : |
| 49 | - echo get_the_title( $discount->ID ); |
|
| 49 | + echo get_the_title($discount->ID); |
|
| 50 | 50 | break; |
| 51 | 51 | case 'code' : |
| 52 | - echo wpinv_get_discount_code( $discount->ID ); |
|
| 52 | + echo wpinv_get_discount_code($discount->ID); |
|
| 53 | 53 | break; |
| 54 | 54 | case 'amount' : |
| 55 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
| 55 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
| 56 | 56 | break; |
| 57 | 57 | case 'usage_limit' : |
| 58 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
| 58 | + echo wpinv_get_discount_uses($discount->ID); |
|
| 59 | 59 | break; |
| 60 | 60 | case 'usage' : |
| 61 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
| 62 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
| 63 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
| 61 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
| 62 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
| 63 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
| 64 | 64 | } else { |
| 65 | 65 | $usage .= ' ∞'; |
| 66 | 66 | } |
@@ -68,162 +68,162 @@ discard block |
||
| 68 | 68 | echo $usage; |
| 69 | 69 | break; |
| 70 | 70 | case 'expiry_date' : |
| 71 | - if ( wpinv_get_discount_expiration( $discount->ID ) ) { |
|
| 72 | - $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) ); |
|
| 71 | + if (wpinv_get_discount_expiration($discount->ID)) { |
|
| 72 | + $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID))); |
|
| 73 | 73 | } else { |
| 74 | - $expiration = __( 'Never', 'invoicing' ); |
|
| 74 | + $expiration = __('Never', 'invoicing'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | echo $expiration; |
| 78 | 78 | break; |
| 79 | 79 | case 'description' : |
| 80 | - echo wp_kses_post( $post->post_excerpt ); |
|
| 80 | + echo wp_kses_post($post->post_excerpt); |
|
| 81 | 81 | break; |
| 82 | 82 | case 'status' : |
| 83 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
| 83 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
| 84 | 84 | |
| 85 | - echo wpinv_discount_status( $status ); |
|
| 85 | + echo wpinv_discount_status($status); |
|
| 86 | 86 | break; |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
| 91 | -function wpinv_post_row_actions( $actions, $post ) { |
|
| 92 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
| 90 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
| 91 | +function wpinv_post_row_actions($actions, $post) { |
|
| 92 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
| 93 | 93 | |
| 94 | - if ( $post_type == 'wpi_invoice' ) { |
|
| 94 | + if ($post_type == 'wpi_invoice') { |
|
| 95 | 95 | $actions = array(); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( $post_type == 'wpi_discount' ) { |
|
| 99 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
| 98 | + if ($post_type == 'wpi_discount') { |
|
| 99 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | return $actions; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
| 106 | - $row_actions = array(); |
|
| 107 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
| 108 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
| 105 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
| 106 | + $row_actions = array(); |
|
| 107 | + $edit_link = get_edit_post_link($discount->ID); |
|
| 108 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
| 109 | 109 | |
| 110 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
| 111 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
| 112 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
| 113 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
| 110 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
| 111 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
| 112 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
| 113 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
| 117 | - if ( isset( $row_actions['delete'] ) ) { |
|
| 118 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
| 116 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
| 117 | + if (isset($row_actions['delete'])) { |
|
| 118 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
| 121 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
| 125 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
| 125 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
| 126 | 126 | |
| 127 | 127 | return $row_actions; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
| 131 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
| 132 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
| 130 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
| 131 | +function wpinv_table_primary_column($default, $screen_id) { |
|
| 132 | + if ('edit-wpi_invoice' === $screen_id) { |
|
| 133 | 133 | return 'name'; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | return $default; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
| 140 | - if ( !$display ) { |
|
| 139 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
| 140 | + if (!$display) { |
|
| 141 | 141 | return array(); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $actions = array( |
| 145 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
| 146 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
| 147 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
| 145 | + 'activate' => __('Activate', 'invoicing'), |
|
| 146 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
| 147 | + 'delete' => __('Delete', 'invoicing'), |
|
| 148 | 148 | ); |
| 149 | 149 | $two = ''; |
| 150 | 150 | $which = 'top'; |
| 151 | 151 | echo '</div><div class="alignleft actions bulkactions">'; |
| 152 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
| 153 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
| 154 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
| 152 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
| 153 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
| 154 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
| 155 | 155 | |
| 156 | - foreach ( $actions as $name => $title ) { |
|
| 156 | + foreach ($actions as $name => $title) { |
|
| 157 | 157 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
| 158 | 158 | |
| 159 | 159 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
| 160 | 160 | } |
| 161 | 161 | echo "</select>"; |
| 162 | 162 | |
| 163 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
| 163 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
| 164 | 164 | |
| 165 | 165 | echo '</div><div class="alignleft actions">'; |
| 166 | 166 | } |
| 167 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
| 167 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
| 168 | 168 | |
| 169 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
| 170 | - if ( $post_type == 'wpi_discount' ) { |
|
| 169 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
| 170 | + if ($post_type == 'wpi_discount') { |
|
| 171 | 171 | $disable = true; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $disable; |
| 175 | 175 | } |
| 176 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
| 176 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
| 177 | 177 | |
| 178 | 178 | function wpinv_restrict_manage_posts() { |
| 179 | 179 | global $typenow; |
| 180 | 180 | |
| 181 | - if( 'wpi_discount' == $typenow ) { |
|
| 181 | + if ('wpi_discount' == $typenow) { |
|
| 182 | 182 | wpinv_discount_filters(); |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
| 185 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
| 186 | 186 | |
| 187 | 187 | function wpinv_discount_filters() { |
| 188 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
| 188 | + echo wpinv_discount_bulk_actions(array(), true); |
|
| 189 | 189 | |
| 190 | 190 | ?> |
| 191 | 191 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
| 192 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
| 192 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
| 193 | 193 | <?php |
| 194 | 194 | $types = wpinv_get_discount_types(); |
| 195 | 195 | |
| 196 | - foreach ( $types as $name => $type ) { |
|
| 197 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 196 | + foreach ($types as $name => $type) { |
|
| 197 | + echo '<option value="' . esc_attr($name) . '"'; |
|
| 198 | 198 | |
| 199 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 200 | - selected( $name, $_GET['discount_type'] ); |
|
| 199 | + if (isset($_GET['discount_type'])) |
|
| 200 | + selected($name, $_GET['discount_type']); |
|
| 201 | 201 | |
| 202 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 202 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
| 203 | 203 | } |
| 204 | 204 | ?> |
| 205 | 205 | </select> |
| 206 | 206 | <?php |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | -function wpinv_request( $vars ) { |
|
| 209 | +function wpinv_request($vars) { |
|
| 210 | 210 | global $typenow, $wp_query, $wp_post_statuses; |
| 211 | 211 | |
| 212 | - if ( 'wpi_invoice' === $typenow or 'wpi_quote' === $typenow ) { |
|
| 213 | - if ( !isset( $vars['post_status'] ) ) { |
|
| 212 | + if ('wpi_invoice' === $typenow or 'wpi_quote' === $typenow) { |
|
| 213 | + if (!isset($vars['post_status'])) { |
|
| 214 | 214 | $post_statuses = wpinv_get_invoice_statuses(); |
| 215 | 215 | |
| 216 | - foreach ( $post_statuses as $status => $value ) { |
|
| 217 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
| 218 | - unset( $post_statuses[ $status ] ); |
|
| 216 | + foreach ($post_statuses as $status => $value) { |
|
| 217 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
| 218 | + unset($post_statuses[$status]); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
| 222 | + $vars['post_status'] = array_keys($post_statuses); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( isset( $vars['orderby'] ) ) { |
|
| 226 | - if ( 'amount' == $vars['orderby'] ) { |
|
| 225 | + if (isset($vars['orderby'])) { |
|
| 226 | + if ('amount' == $vars['orderby']) { |
|
| 227 | 227 | $vars = array_merge( |
| 228 | 228 | $vars, |
| 229 | 229 | array( |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | 'orderby' => 'meta_value_num' |
| 232 | 232 | ) |
| 233 | 233 | ); |
| 234 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
| 234 | + } else if ('customer' == $vars['orderby']) { |
|
| 235 | 235 | $vars = array_merge( |
| 236 | 236 | $vars, |
| 237 | 237 | array( |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | ); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | - } else if ( 'wpi_item' == $typenow ) { |
|
| 244 | + } else if ('wpi_item' == $typenow) { |
|
| 245 | 245 | // Check if 'orderby' is set to "price" |
| 246 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
| 246 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
| 247 | 247 | $vars = array_merge( |
| 248 | 248 | $vars, |
| 249 | 249 | array( |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // Check if "orderby" is set to "vat_rule" |
| 257 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
| 257 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
| 258 | 258 | $vars = array_merge( |
| 259 | 259 | $vars, |
| 260 | 260 | array( |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Check if "orderby" is set to "vat_class" |
| 268 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
| 268 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
| 269 | 269 | $vars = array_merge( |
| 270 | 270 | $vars, |
| 271 | 271 | array( |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | // Check if "orderby" is set to "type" |
| 279 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
| 279 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
| 280 | 280 | $vars = array_merge( |
| 281 | 281 | $vars, |
| 282 | 282 | array( |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | // Check if "orderby" is set to "recurring" |
| 290 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
| 290 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
| 291 | 291 | $vars = array_merge( |
| 292 | 292 | $vars, |
| 293 | 293 | array( |
@@ -297,120 +297,120 @@ discard block |
||
| 297 | 297 | ); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 300 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 301 | 301 | // Filter vat rule type |
| 302 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
| 302 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
| 303 | 303 | $meta_query[] = array( |
| 304 | 304 | 'key' => '_wpinv_vat_rule', |
| 305 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
| 305 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
| 306 | 306 | 'compare' => '=' |
| 307 | 307 | ); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Filter vat class |
| 311 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
| 311 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
| 312 | 312 | $meta_query[] = array( |
| 313 | 313 | 'key' => '_wpinv_vat_class', |
| 314 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
| 314 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
| 315 | 315 | 'compare' => '=' |
| 316 | 316 | ); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | // Filter item type |
| 320 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
| 320 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
| 321 | 321 | $meta_query[] = array( |
| 322 | 322 | 'key' => '_wpinv_type', |
| 323 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
| 323 | + 'value' => sanitize_text_field($_GET['type']), |
|
| 324 | 324 | 'compare' => '=' |
| 325 | 325 | ); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( !empty( $meta_query ) ) { |
|
| 328 | + if (!empty($meta_query)) { |
|
| 329 | 329 | $vars['meta_query'] = $meta_query; |
| 330 | 330 | } |
| 331 | - } else if ( 'wpi_discount' == $typenow ) { |
|
| 332 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 331 | + } else if ('wpi_discount' == $typenow) { |
|
| 332 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 333 | 333 | // Filter vat rule type |
| 334 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
| 334 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
| 335 | 335 | $meta_query[] = array( |
| 336 | 336 | 'key' => '_wpi_discount_type', |
| 337 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
| 337 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
| 338 | 338 | 'compare' => '=' |
| 339 | 339 | ); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if ( !empty( $meta_query ) ) { |
|
| 342 | + if (!empty($meta_query)) { |
|
| 343 | 343 | $vars['meta_query'] = $meta_query; |
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | return $vars; |
| 348 | 348 | } |
| 349 | -add_filter( 'request', 'wpinv_request' ); |
|
| 349 | +add_filter('request', 'wpinv_request'); |
|
| 350 | 350 | |
| 351 | 351 | function wpinv_options_page() { |
| 352 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 352 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 353 | 353 | |
| 354 | - if ( $page !== 'wpinv-settings' ) { |
|
| 354 | + if ($page !== 'wpinv-settings') { |
|
| 355 | 355 | return; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | $settings_tabs = wpinv_get_settings_tabs(); |
| 359 | 359 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
| 360 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
| 361 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 360 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
| 361 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 362 | 362 | $key = 'main'; |
| 363 | 363 | |
| 364 | - if ( is_array( $sections ) ) { |
|
| 365 | - $key = key( $sections ); |
|
| 364 | + if (is_array($sections)) { |
|
| 365 | + $key = key($sections); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 369 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
| 368 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 369 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
| 370 | 370 | ob_start(); |
| 371 | 371 | ?> |
| 372 | 372 | <div class="wrap"> |
| 373 | 373 | <h1 class="nav-tab-wrapper"> |
| 374 | 374 | <?php |
| 375 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
| 376 | - $tab_url = add_query_arg( array( |
|
| 375 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
| 376 | + $tab_url = add_query_arg(array( |
|
| 377 | 377 | 'settings-updated' => false, |
| 378 | 378 | 'tab' => $tab_id, |
| 379 | - ) ); |
|
| 379 | + )); |
|
| 380 | 380 | |
| 381 | 381 | // Remove the section from the tabs so we always end up at the main section |
| 382 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
| 383 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 382 | + $tab_url = remove_query_arg('section', $tab_url); |
|
| 383 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 384 | 384 | |
| 385 | 385 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
| 386 | 386 | |
| 387 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
| 388 | - echo esc_html( $tab_name ); |
|
| 387 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
| 388 | + echo esc_html($tab_name); |
|
| 389 | 389 | echo '</a>'; |
| 390 | 390 | } |
| 391 | 391 | ?> |
| 392 | 392 | </h1> |
| 393 | 393 | <?php |
| 394 | - $number_of_sections = count( $sections ); |
|
| 394 | + $number_of_sections = count($sections); |
|
| 395 | 395 | $number = 0; |
| 396 | - if ( $number_of_sections > 1 ) { |
|
| 396 | + if ($number_of_sections > 1) { |
|
| 397 | 397 | echo '<div><ul class="subsubsub">'; |
| 398 | - foreach( $sections as $section_id => $section_name ) { |
|
| 398 | + foreach ($sections as $section_id => $section_name) { |
|
| 399 | 399 | echo '<li>'; |
| 400 | 400 | $number++; |
| 401 | - $tab_url = add_query_arg( array( |
|
| 401 | + $tab_url = add_query_arg(array( |
|
| 402 | 402 | 'settings-updated' => false, |
| 403 | 403 | 'tab' => $active_tab, |
| 404 | 404 | 'section' => $section_id |
| 405 | - ) ); |
|
| 406 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 405 | + )); |
|
| 406 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 407 | 407 | $class = ''; |
| 408 | - if ( $section == $section_id ) { |
|
| 408 | + if ($section == $section_id) { |
|
| 409 | 409 | $class = 'current'; |
| 410 | 410 | } |
| 411 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
| 411 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
| 412 | 412 | |
| 413 | - if ( $number != $number_of_sections ) { |
|
| 413 | + if ($number != $number_of_sections) { |
|
| 414 | 414 | echo ' | '; |
| 415 | 415 | } |
| 416 | 416 | echo '</li>'; |
@@ -422,19 +422,19 @@ discard block |
||
| 422 | 422 | <form method="post" action="options.php"> |
| 423 | 423 | <table class="form-table"> |
| 424 | 424 | <?php |
| 425 | - settings_fields( 'wpinv_settings' ); |
|
| 425 | + settings_fields('wpinv_settings'); |
|
| 426 | 426 | |
| 427 | - if ( 'main' === $section ) { |
|
| 428 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
| 427 | + if ('main' === $section) { |
|
| 428 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section ); |
|
| 432 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section ); |
|
| 433 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section ); |
|
| 431 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section); |
|
| 432 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section); |
|
| 433 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section); |
|
| 434 | 434 | |
| 435 | 435 | // For backwards compatibility |
| 436 | - if ( 'main' === $section ) { |
|
| 437 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
| 436 | + if ('main' === $section) { |
|
| 437 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
| 438 | 438 | } |
| 439 | 439 | ?> |
| 440 | 440 | </table> |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | echo $content; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
| 450 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
| 451 | 451 | global $pagenow, $typenow; |
| 452 | 452 | |
| 453 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
| 454 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
| 453 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && $type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
| 454 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
| 455 | 455 | } |
| 456 | 456 | return $classes; |
| 457 | 457 | } |
| 458 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
| 459 | 458 | \ No newline at end of file |
| 459 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
| 460 | 460 | \ No newline at end of file |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -register_activation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_activation' ); |
|
| 3 | -register_deactivation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation' ); |
|
| 2 | +register_activation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_activation'); |
|
| 3 | +register_deactivation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation'); |
|
| 4 | 4 | |
| 5 | -function wpinv_plugin_activation( $network_wide = false ) { |
|
| 6 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
| 7 | - wpinv_install( $network_wide ); |
|
| 5 | +function wpinv_plugin_activation($network_wide = false) { |
|
| 6 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
| 7 | + wpinv_install($network_wide); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | function wpinv_plugin_deactivation() { |
| 11 | 11 | // plugin deactivation stuff |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_install( $network_wide = false ) { |
|
| 14 | +function wpinv_install($network_wide = false) { |
|
| 15 | 15 | global $wpdb; |
| 16 | 16 | |
| 17 | - if ( is_multisite() && $network_wide ) { |
|
| 18 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
| 19 | - switch_to_blog( $blog_id ); |
|
| 17 | + if (is_multisite() && $network_wide) { |
|
| 18 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
| 19 | + switch_to_blog($blog_id); |
|
| 20 | 20 | wpinv_run_install(); |
| 21 | 21 | restore_current_blog(); |
| 22 | 22 | } |
@@ -32,75 +32,75 @@ discard block |
||
| 32 | 32 | wpinv_register_post_types(); |
| 33 | 33 | |
| 34 | 34 | // Clear the permalinks |
| 35 | - flush_rewrite_rules( false ); |
|
| 35 | + flush_rewrite_rules(false); |
|
| 36 | 36 | |
| 37 | 37 | // Add Upgraded From Option |
| 38 | - $current_version = get_option( 'wpinv_version' ); |
|
| 39 | - if ( $current_version ) { |
|
| 40 | - update_option( 'wpinv_version_upgraded_from', $current_version ); |
|
| 38 | + $current_version = get_option('wpinv_version'); |
|
| 39 | + if ($current_version) { |
|
| 40 | + update_option('wpinv_version_upgraded_from', $current_version); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Pull options from WP, not GD Invoice's global |
| 44 | - $current_options = get_option( 'wpinv_settings', array() ); |
|
| 44 | + $current_options = get_option('wpinv_settings', array()); |
|
| 45 | 45 | |
| 46 | 46 | // Setup some default options |
| 47 | 47 | $options = wpinv_create_pages(); |
| 48 | 48 | |
| 49 | 49 | // Populate some default values |
| 50 | - foreach( wpinv_get_registered_settings() as $tab => $sections ) { |
|
| 51 | - foreach( $sections as $section => $settings) { |
|
| 50 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
| 51 | + foreach ($sections as $section => $settings) { |
|
| 52 | 52 | // Check for backwards compatibility |
| 53 | - $tab_sections = wpinv_get_settings_tab_sections( $tab ); |
|
| 54 | - if( ! is_array( $tab_sections ) || ! array_key_exists( $section, $tab_sections ) ) { |
|
| 53 | + $tab_sections = wpinv_get_settings_tab_sections($tab); |
|
| 54 | + if (!is_array($tab_sections) || !array_key_exists($section, $tab_sections)) { |
|
| 55 | 55 | $section = 'main'; |
| 56 | 56 | $settings = $sections; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - foreach ( $settings as $option ) { |
|
| 60 | - if ( !empty( $option['id'] ) && !isset( $wpinv_options[ $option['id'] ] ) ) { |
|
| 61 | - if ( 'checkbox' == $option['type'] && !empty( $option['std'] ) ) { |
|
| 62 | - $options[ $option['id'] ] = '1'; |
|
| 63 | - } else if ( !empty( $option['std'] ) ) { |
|
| 64 | - $options[ $option['id'] ] = $option['std']; |
|
| 59 | + foreach ($settings as $option) { |
|
| 60 | + if (!empty($option['id']) && !isset($wpinv_options[$option['id']])) { |
|
| 61 | + if ('checkbox' == $option['type'] && !empty($option['std'])) { |
|
| 62 | + $options[$option['id']] = '1'; |
|
| 63 | + } else if (!empty($option['std'])) { |
|
| 64 | + $options[$option['id']] = $option['std']; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $merged_options = array_merge( $wpinv_options, $options ); |
|
| 71 | + $merged_options = array_merge($wpinv_options, $options); |
|
| 72 | 72 | $wpinv_options = $merged_options; |
| 73 | 73 | |
| 74 | - update_option( 'wpinv_settings', $merged_options ); |
|
| 75 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
| 74 | + update_option('wpinv_settings', $merged_options); |
|
| 75 | + update_option('wpinv_version', WPINV_VERSION); |
|
| 76 | 76 | |
| 77 | 77 | // Check for PHP Session support, and enable if available |
| 78 | 78 | $wpi_session->use_php_sessions(); |
| 79 | 79 | |
| 80 | 80 | // Add a temporary option to note that GD Invoice pages have been created |
| 81 | - set_transient( '_wpinv_installed', $merged_options, 30 ); |
|
| 81 | + set_transient('_wpinv_installed', $merged_options, 30); |
|
| 82 | 82 | |
| 83 | 83 | // Bail if activating from network, or bulk |
| 84 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 84 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 85 | 85 | return; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Add the transient to redirect |
| 89 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
| 89 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * When a new Blog is created in multisite, see if Invoicing is network activated, and run the installer. |
| 94 | 94 | * |
| 95 | 95 | */ |
| 96 | -function wpinv_new_blog_created( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 97 | - if ( is_plugin_active_for_network( plugin_basename( WPINV_PLUGIN_FILE ) ) ) { |
|
| 98 | - switch_to_blog( $blog_id ); |
|
| 96 | +function wpinv_new_blog_created($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 97 | + if (is_plugin_active_for_network(plugin_basename(WPINV_PLUGIN_FILE))) { |
|
| 98 | + switch_to_blog($blog_id); |
|
| 99 | 99 | wpinv_run_install(); |
| 100 | 100 | restore_current_blog(); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | -add_action( 'wpmu_new_blog', 'wpinv_new_blog_created', 10, 6 ); |
|
| 103 | +add_action('wpmu_new_blog', 'wpinv_new_blog_created', 10, 6); |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * Post-installation. |
@@ -108,23 +108,23 @@ discard block |
||
| 108 | 108 | * Runs just after plugin installation and exposes the wpinv_after_install hook. |
| 109 | 109 | */ |
| 110 | 110 | function wpinv_after_install() { |
| 111 | - if ( ! is_admin() ) { |
|
| 111 | + if (!is_admin()) { |
|
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $wpinv_options = get_transient( '_wpinv_installed' ); |
|
| 116 | - $wpinv_table_check = get_option( '_wpinv_table_check', false ); |
|
| 115 | + $wpinv_options = get_transient('_wpinv_installed'); |
|
| 116 | + $wpinv_table_check = get_option('_wpinv_table_check', false); |
|
| 117 | 117 | |
| 118 | - if ( false === $wpinv_table_check || current_time( 'timestamp' ) > $wpinv_table_check ) { |
|
| 119 | - update_option( '_wpinv_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
| 118 | + if (false === $wpinv_table_check || current_time('timestamp') > $wpinv_table_check) { |
|
| 119 | + update_option('_wpinv_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ( false !== $wpinv_options ) { |
|
| 122 | + if (false !== $wpinv_options) { |
|
| 123 | 123 | // Delete the transient |
| 124 | - delete_transient( '_wpinv_installed' ); |
|
| 124 | + delete_transient('_wpinv_installed'); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | -add_action( 'admin_init', 'wpinv_after_install' ); |
|
| 127 | +add_action('admin_init', 'wpinv_after_install'); |
|
| 128 | 128 | |
| 129 | 129 | function wpinv_create_pages() { |
| 130 | 130 | global $wpinv_options; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $options = array(); |
| 133 | 133 | |
| 134 | 134 | // Checks if the purchase page option exists |
| 135 | - if ( ! array_key_exists( 'checkout_page', $wpinv_options ) ) { |
|
| 135 | + if (!array_key_exists('checkout_page', $wpinv_options)) { |
|
| 136 | 136 | // Checkout Page |
| 137 | 137 | $checkout = wp_insert_post( |
| 138 | 138 | array( |
| 139 | - 'post_title' => __( 'Checkout', 'invoicing' ), |
|
| 139 | + 'post_title' => __('Checkout', 'invoicing'), |
|
| 140 | 140 | 'post_content' => '[wpinv_checkout]', |
| 141 | 141 | 'post_status' => 'publish', |
| 142 | 142 | 'post_author' => 1, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | // Invoice History (History) Page |
| 151 | 151 | $history = wp_insert_post( |
| 152 | 152 | array( |
| 153 | - 'post_title' => __( 'Invoice History', 'invoicing' ), |
|
| 153 | + 'post_title' => __('Invoice History', 'invoicing'), |
|
| 154 | 154 | 'post_content' => '[wpinv_history]', |
| 155 | 155 | 'post_status' => 'publish', |
| 156 | 156 | 'post_author' => 1, |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | // Payment Confirmation (Success) Page |
| 165 | 165 | $success = wp_insert_post( |
| 166 | 166 | array( |
| 167 | - 'post_title' => __( 'Payment Confirmation', 'invoicing' ), |
|
| 168 | - 'post_content' => __( '[wpinv_receipt]', 'invoicing' ), |
|
| 167 | + 'post_title' => __('Payment Confirmation', 'invoicing'), |
|
| 168 | + 'post_content' => __('[wpinv_receipt]', 'invoicing'), |
|
| 169 | 169 | 'post_status' => 'publish', |
| 170 | 170 | 'post_author' => 1, |
| 171 | 171 | 'post_parent' => $checkout, |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | // Failed Payment Page |
| 179 | 179 | $failed = wp_insert_post( |
| 180 | 180 | array( |
| 181 | - 'post_title' => __( 'Transaction Failed', 'invoicing' ), |
|
| 182 | - 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 181 | + 'post_title' => __('Transaction Failed', 'invoicing'), |
|
| 182 | + 'post_content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
| 183 | 183 | 'post_status' => 'publish', |
| 184 | 184 | 'post_author' => 1, |
| 185 | 185 | 'post_type' => 'page', |
@@ -770,326 +770,326 @@ discard block |
||
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
| 773 | - $pages_options = array(); |
|
| 773 | + $pages_options = array(); |
|
| 774 | 774 | |
| 775 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 776 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 777 | - } |
|
| 775 | + if( $default_label !== NULL && $default_label !== false ) { |
|
| 776 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 777 | + } |
|
| 778 | 778 | |
| 779 | - $pages = get_pages(); |
|
| 780 | - if ( $pages ) { |
|
| 781 | - foreach ( $pages as $page ) { |
|
| 782 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 779 | + $pages = get_pages(); |
|
| 780 | + if ( $pages ) { |
|
| 781 | + foreach ( $pages as $page ) { |
|
| 782 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 783 | 783 | $pages_options[ $page->ID ] = $title; |
| 784 | - } |
|
| 785 | - } |
|
| 784 | + } |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - return $pages_options; |
|
| 787 | + return $pages_options; |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | function wpinv_header_callback( $args ) { |
| 791 | - if ( !empty( $args['desc'] ) ) { |
|
| 791 | + if ( !empty( $args['desc'] ) ) { |
|
| 792 | 792 | echo $args['desc']; |
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | function wpinv_hidden_callback( $args ) { |
| 797 | - global $wpinv_options; |
|
| 798 | - |
|
| 799 | - if ( isset( $args['set_value'] ) ) { |
|
| 800 | - $value = $args['set_value']; |
|
| 801 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 802 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 803 | - } else { |
|
| 804 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 808 | - $args['readonly'] = true; |
|
| 809 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 810 | - $name = ''; |
|
| 811 | - } else { |
|
| 812 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 797 | + global $wpinv_options; |
|
| 798 | + |
|
| 799 | + if ( isset( $args['set_value'] ) ) { |
|
| 800 | + $value = $args['set_value']; |
|
| 801 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 802 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 803 | + } else { |
|
| 804 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 808 | + $args['readonly'] = true; |
|
| 809 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 810 | + $name = ''; |
|
| 811 | + } else { |
|
| 812 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 816 | 816 | |
| 817 | - echo $html; |
|
| 817 | + echo $html; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | function wpinv_checkbox_callback( $args ) { |
| 821 | - global $wpinv_options; |
|
| 821 | + global $wpinv_options; |
|
| 822 | 822 | |
| 823 | 823 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 824 | 824 | |
| 825 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 826 | - $name = ''; |
|
| 827 | - } else { |
|
| 828 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 829 | - } |
|
| 825 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 826 | + $name = ''; |
|
| 827 | + } else { |
|
| 828 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 829 | + } |
|
| 830 | 830 | |
| 831 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 832 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 833 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 831 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 832 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 833 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 834 | 834 | |
| 835 | - echo $html; |
|
| 835 | + echo $html; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | function wpinv_multicheck_callback( $args ) { |
| 839 | - global $wpinv_options; |
|
| 839 | + global $wpinv_options; |
|
| 840 | 840 | |
| 841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 841 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 842 | 842 | |
| 843 | - if ( ! empty( $args['options'] ) ) { |
|
| 844 | - foreach( $args['options'] as $key => $option ): |
|
| 845 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 846 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 847 | - $enabled = $sanitize_key; |
|
| 848 | - } else { |
|
| 849 | - $enabled = NULL; |
|
| 850 | - } |
|
| 851 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 852 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 853 | - endforeach; |
|
| 854 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 855 | - } |
|
| 843 | + if ( ! empty( $args['options'] ) ) { |
|
| 844 | + foreach( $args['options'] as $key => $option ): |
|
| 845 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 846 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 847 | + $enabled = $sanitize_key; |
|
| 848 | + } else { |
|
| 849 | + $enabled = NULL; |
|
| 850 | + } |
|
| 851 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 852 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 853 | + endforeach; |
|
| 854 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 855 | + } |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | function wpinv_payment_icons_callback( $args ) { |
| 859 | - global $wpinv_options; |
|
| 859 | + global $wpinv_options; |
|
| 860 | 860 | |
| 861 | 861 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 862 | 862 | |
| 863 | - if ( ! empty( $args['options'] ) ) { |
|
| 864 | - foreach( $args['options'] as $key => $option ) { |
|
| 863 | + if ( ! empty( $args['options'] ) ) { |
|
| 864 | + foreach( $args['options'] as $key => $option ) { |
|
| 865 | 865 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 866 | 866 | |
| 867 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 868 | - $enabled = $option; |
|
| 869 | - } else { |
|
| 870 | - $enabled = NULL; |
|
| 871 | - } |
|
| 872 | - |
|
| 873 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 874 | - |
|
| 875 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 876 | - |
|
| 877 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 878 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 879 | - } else { |
|
| 880 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 881 | - |
|
| 882 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 883 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 884 | - } else { |
|
| 885 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 886 | - $content_dir = WP_CONTENT_DIR; |
|
| 887 | - |
|
| 888 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 889 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 890 | - $image = wp_normalize_path( $image ); |
|
| 891 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 892 | - } |
|
| 893 | - |
|
| 894 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 895 | - } |
|
| 896 | - |
|
| 897 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 898 | - } |
|
| 899 | - echo $option . '</label>'; |
|
| 900 | - } |
|
| 901 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 902 | - } |
|
| 867 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 868 | + $enabled = $option; |
|
| 869 | + } else { |
|
| 870 | + $enabled = NULL; |
|
| 871 | + } |
|
| 872 | + |
|
| 873 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 874 | + |
|
| 875 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 876 | + |
|
| 877 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 878 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 879 | + } else { |
|
| 880 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 881 | + |
|
| 882 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 883 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 884 | + } else { |
|
| 885 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 886 | + $content_dir = WP_CONTENT_DIR; |
|
| 887 | + |
|
| 888 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 889 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 890 | + $image = wp_normalize_path( $image ); |
|
| 891 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 892 | + } |
|
| 893 | + |
|
| 894 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 895 | + } |
|
| 896 | + |
|
| 897 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 898 | + } |
|
| 899 | + echo $option . '</label>'; |
|
| 900 | + } |
|
| 901 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 902 | + } |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | function wpinv_radio_callback( $args ) { |
| 906 | - global $wpinv_options; |
|
| 906 | + global $wpinv_options; |
|
| 907 | 907 | |
| 908 | 908 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 909 | 909 | |
| 910 | 910 | foreach ( $args['options'] as $key => $option ) : |
| 911 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 911 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 912 | 912 | |
| 913 | 913 | $checked = false; |
| 914 | 914 | |
| 915 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 916 | - $checked = true; |
|
| 917 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 918 | - $checked = true; |
|
| 915 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 916 | + $checked = true; |
|
| 917 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 918 | + $checked = true; |
|
| 919 | 919 | |
| 920 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 921 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 922 | - endforeach; |
|
| 920 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 921 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 922 | + endforeach; |
|
| 923 | 923 | |
| 924 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 924 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | function wpinv_gateways_callback( $args ) { |
| 928 | - global $wpinv_options; |
|
| 928 | + global $wpinv_options; |
|
| 929 | 929 | |
| 930 | 930 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 931 | 931 | |
| 932 | - foreach ( $args['options'] as $key => $option ) : |
|
| 933 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 932 | + foreach ( $args['options'] as $key => $option ) : |
|
| 933 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 934 | 934 | |
| 935 | 935 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
| 936 | - $enabled = '1'; |
|
| 937 | - else |
|
| 938 | - $enabled = null; |
|
| 936 | + $enabled = '1'; |
|
| 937 | + else |
|
| 938 | + $enabled = null; |
|
| 939 | 939 | |
| 940 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 941 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 942 | - endforeach; |
|
| 940 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 941 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 942 | + endforeach; |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | function wpinv_gateway_select_callback($args) { |
| 946 | - global $wpinv_options; |
|
| 946 | + global $wpinv_options; |
|
| 947 | 947 | |
| 948 | 948 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 949 | 949 | |
| 950 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
| 950 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
| 951 | 951 | |
| 952 | - foreach ( $args['options'] as $key => $option ) : |
|
| 953 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 952 | + foreach ( $args['options'] as $key => $option ) : |
|
| 953 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 954 | 954 | $selected = selected( $key, $args['selected'], false ); |
| 955 | 955 | } else { |
| 956 | 956 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
| 957 | 957 | } |
| 958 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 959 | - endforeach; |
|
| 958 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 959 | + endforeach; |
|
| 960 | 960 | |
| 961 | - echo '</select>'; |
|
| 962 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 961 | + echo '</select>'; |
|
| 962 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | function wpinv_text_callback( $args ) { |
| 966 | - global $wpinv_options; |
|
| 966 | + global $wpinv_options; |
|
| 967 | 967 | |
| 968 | 968 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 969 | 969 | |
| 970 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 971 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 972 | - } else { |
|
| 973 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 974 | - } |
|
| 975 | - |
|
| 976 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 977 | - $args['readonly'] = true; |
|
| 978 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 979 | - $name = ''; |
|
| 980 | - } else { |
|
| 981 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 985 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 986 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 987 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 988 | - |
|
| 989 | - echo $html; |
|
| 970 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 971 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 972 | + } else { |
|
| 973 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 977 | + $args['readonly'] = true; |
|
| 978 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 979 | + $name = ''; |
|
| 980 | + } else { |
|
| 981 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 985 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 986 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 987 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 988 | + |
|
| 989 | + echo $html; |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | function wpinv_number_callback( $args ) { |
| 993 | - global $wpinv_options; |
|
| 993 | + global $wpinv_options; |
|
| 994 | 994 | |
| 995 | 995 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 996 | 996 | |
| 997 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 998 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 999 | - } else { |
|
| 1000 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1004 | - $args['readonly'] = true; |
|
| 1005 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1006 | - $name = ''; |
|
| 1007 | - } else { |
|
| 1008 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1012 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1013 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1014 | - |
|
| 1015 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1016 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1017 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1018 | - |
|
| 1019 | - echo $html; |
|
| 997 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 998 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 999 | + } else { |
|
| 1000 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1004 | + $args['readonly'] = true; |
|
| 1005 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1006 | + $name = ''; |
|
| 1007 | + } else { |
|
| 1008 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1012 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1013 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1014 | + |
|
| 1015 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1016 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1017 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1018 | + |
|
| 1019 | + echo $html; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | function wpinv_textarea_callback( $args ) { |
| 1023 | - global $wpinv_options; |
|
| 1023 | + global $wpinv_options; |
|
| 1024 | 1024 | |
| 1025 | 1025 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1026 | 1026 | |
| 1027 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1028 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1029 | - } else { |
|
| 1030 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1031 | - } |
|
| 1027 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1028 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1029 | + } else { |
|
| 1030 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1031 | + } |
|
| 1032 | 1032 | |
| 1033 | 1033 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 1034 | 1034 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 1035 | 1035 | |
| 1036 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1037 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1036 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1037 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1038 | 1038 | |
| 1039 | - echo $html; |
|
| 1039 | + echo $html; |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | function wpinv_password_callback( $args ) { |
| 1043 | - global $wpinv_options; |
|
| 1043 | + global $wpinv_options; |
|
| 1044 | 1044 | |
| 1045 | 1045 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1046 | 1046 | |
| 1047 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1048 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1049 | - } else { |
|
| 1050 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1051 | - } |
|
| 1047 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1048 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1049 | + } else { |
|
| 1050 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1051 | + } |
|
| 1052 | 1052 | |
| 1053 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1054 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1055 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1053 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1054 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1055 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1056 | 1056 | |
| 1057 | - echo $html; |
|
| 1057 | + echo $html; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | function wpinv_missing_callback($args) { |
| 1061 | - printf( |
|
| 1062 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1063 | - '<strong>' . $args['id'] . '</strong>' |
|
| 1064 | - ); |
|
| 1061 | + printf( |
|
| 1062 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1063 | + '<strong>' . $args['id'] . '</strong>' |
|
| 1064 | + ); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | function wpinv_select_callback($args) { |
| 1068 | - global $wpinv_options; |
|
| 1068 | + global $wpinv_options; |
|
| 1069 | 1069 | |
| 1070 | 1070 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1071 | 1071 | |
| 1072 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1073 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1074 | - } else { |
|
| 1075 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1076 | - } |
|
| 1072 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1073 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1074 | + } else { |
|
| 1075 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
| 1079 | 1079 | $value = $args['selected']; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1083 | - $placeholder = $args['placeholder']; |
|
| 1084 | - } else { |
|
| 1085 | - $placeholder = ''; |
|
| 1086 | - } |
|
| 1087 | - |
|
| 1088 | - if ( isset( $args['chosen'] ) ) { |
|
| 1089 | - $chosen = 'class="wpinv-chosen"'; |
|
| 1090 | - } else { |
|
| 1091 | - $chosen = ''; |
|
| 1092 | - } |
|
| 1082 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1083 | + $placeholder = $args['placeholder']; |
|
| 1084 | + } else { |
|
| 1085 | + $placeholder = ''; |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + if ( isset( $args['chosen'] ) ) { |
|
| 1089 | + $chosen = 'class="wpinv-chosen"'; |
|
| 1090 | + } else { |
|
| 1091 | + $chosen = ''; |
|
| 1092 | + } |
|
| 1093 | 1093 | |
| 1094 | 1094 | if( !empty( $args['onchange'] ) ) { |
| 1095 | 1095 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1097,143 +1097,143 @@ discard block |
||
| 1097 | 1097 | $onchange = ''; |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1100 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1101 | 1101 | |
| 1102 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1103 | - $selected = selected( $option, $value, false ); |
|
| 1104 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1105 | - } |
|
| 1102 | + foreach ( $args['options'] as $option => $name ) { |
|
| 1103 | + $selected = selected( $option, $value, false ); |
|
| 1104 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | - $html .= '</select>'; |
|
| 1108 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1107 | + $html .= '</select>'; |
|
| 1108 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1109 | 1109 | |
| 1110 | - echo $html; |
|
| 1110 | + echo $html; |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | function wpinv_color_select_callback( $args ) { |
| 1114 | - global $wpinv_options; |
|
| 1114 | + global $wpinv_options; |
|
| 1115 | 1115 | |
| 1116 | 1116 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1117 | 1117 | |
| 1118 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1119 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1120 | - } else { |
|
| 1121 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1122 | - } |
|
| 1118 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1119 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1120 | + } else { |
|
| 1121 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1122 | + } |
|
| 1123 | 1123 | |
| 1124 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1124 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1125 | 1125 | |
| 1126 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1127 | - $selected = selected( $option, $value, false ); |
|
| 1128 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1129 | - } |
|
| 1126 | + foreach ( $args['options'] as $option => $color ) { |
|
| 1127 | + $selected = selected( $option, $value, false ); |
|
| 1128 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | - $html .= '</select>'; |
|
| 1132 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1131 | + $html .= '</select>'; |
|
| 1132 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1133 | 1133 | |
| 1134 | - echo $html; |
|
| 1134 | + echo $html; |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | function wpinv_rich_editor_callback( $args ) { |
| 1138 | - global $wpinv_options, $wp_version; |
|
| 1138 | + global $wpinv_options, $wp_version; |
|
| 1139 | 1139 | |
| 1140 | 1140 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1141 | 1141 | |
| 1142 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1143 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1142 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1143 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1144 | 1144 | |
| 1145 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1146 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1147 | - } |
|
| 1148 | - } else { |
|
| 1149 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1150 | - } |
|
| 1145 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1146 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1147 | + } |
|
| 1148 | + } else { |
|
| 1149 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1150 | + } |
|
| 1151 | 1151 | |
| 1152 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1152 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1153 | 1153 | |
| 1154 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1155 | - ob_start(); |
|
| 1156 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1157 | - $html = ob_get_clean(); |
|
| 1158 | - } else { |
|
| 1159 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1160 | - } |
|
| 1154 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1155 | + ob_start(); |
|
| 1156 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1157 | + $html = ob_get_clean(); |
|
| 1158 | + } else { |
|
| 1159 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1162 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1163 | 1163 | |
| 1164 | - echo $html; |
|
| 1164 | + echo $html; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | function wpinv_upload_callback( $args ) { |
| 1168 | - global $wpinv_options; |
|
| 1168 | + global $wpinv_options; |
|
| 1169 | 1169 | |
| 1170 | 1170 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1171 | 1171 | |
| 1172 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1173 | - $value = $wpinv_options[$args['id']]; |
|
| 1174 | - } else { |
|
| 1175 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1176 | - } |
|
| 1172 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1173 | + $value = $wpinv_options[$args['id']]; |
|
| 1174 | + } else { |
|
| 1175 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1176 | + } |
|
| 1177 | 1177 | |
| 1178 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1179 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1180 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1181 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1178 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1179 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1180 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1181 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1182 | 1182 | |
| 1183 | - echo $html; |
|
| 1183 | + echo $html; |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | function wpinv_color_callback( $args ) { |
| 1187 | - global $wpinv_options; |
|
| 1187 | + global $wpinv_options; |
|
| 1188 | 1188 | |
| 1189 | 1189 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1190 | 1190 | |
| 1191 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1192 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1193 | - } else { |
|
| 1194 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1195 | - } |
|
| 1191 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1192 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1193 | + } else { |
|
| 1194 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1197 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1198 | 1198 | |
| 1199 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1200 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1199 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1200 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1201 | 1201 | |
| 1202 | - echo $html; |
|
| 1202 | + echo $html; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | function wpinv_country_states_callback($args) { |
| 1206 | - global $wpinv_options; |
|
| 1206 | + global $wpinv_options; |
|
| 1207 | 1207 | |
| 1208 | 1208 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1209 | 1209 | |
| 1210 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1211 | - $placeholder = $args['placeholder']; |
|
| 1212 | - } else { |
|
| 1213 | - $placeholder = ''; |
|
| 1214 | - } |
|
| 1210 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1211 | + $placeholder = $args['placeholder']; |
|
| 1212 | + } else { |
|
| 1213 | + $placeholder = ''; |
|
| 1214 | + } |
|
| 1215 | 1215 | |
| 1216 | - $states = wpinv_get_country_states(); |
|
| 1216 | + $states = wpinv_get_country_states(); |
|
| 1217 | 1217 | |
| 1218 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1219 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1220 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1218 | + $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1219 | + $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1220 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1221 | 1221 | |
| 1222 | - foreach ( $states as $option => $name ) { |
|
| 1223 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1224 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1225 | - } |
|
| 1222 | + foreach ( $states as $option => $name ) { |
|
| 1223 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1224 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1225 | + } |
|
| 1226 | 1226 | |
| 1227 | - $html .= '</select>'; |
|
| 1228 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1227 | + $html .= '</select>'; |
|
| 1228 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1229 | 1229 | |
| 1230 | - echo $html; |
|
| 1230 | + echo $html; |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | function wpinv_tax_rates_callback($args) { |
| 1234 | - global $wpinv_options; |
|
| 1235 | - $rates = wpinv_get_tax_rates(); |
|
| 1236 | - ob_start(); ?> |
|
| 1234 | + global $wpinv_options; |
|
| 1235 | + $rates = wpinv_get_tax_rates(); |
|
| 1236 | + ob_start(); ?> |
|
| 1237 | 1237 | </td><tr> |
| 1238 | 1238 | <td colspan="2" class="wpinv_tax_tdbox"> |
| 1239 | 1239 | <p><?php echo $args['desc']; ?></p> |
@@ -1257,41 +1257,41 @@ discard block |
||
| 1257 | 1257 | <tr> |
| 1258 | 1258 | <td class="wpinv_tax_country"> |
| 1259 | 1259 | <?php |
| 1260 | - echo wpinv_html_select( array( |
|
| 1261 | - 'options' => wpinv_get_country_list( true ), |
|
| 1262 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1260 | + echo wpinv_html_select( array( |
|
| 1261 | + 'options' => wpinv_get_country_list( true ), |
|
| 1262 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1263 | 1263 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1264 | - 'selected' => $rate['country'], |
|
| 1265 | - 'show_option_all' => false, |
|
| 1266 | - 'show_option_none' => false, |
|
| 1267 | - 'class' => 'wpinv-tax-country', |
|
| 1268 | - 'chosen' => false, |
|
| 1269 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1270 | - ) ); |
|
| 1271 | - ?> |
|
| 1264 | + 'selected' => $rate['country'], |
|
| 1265 | + 'show_option_all' => false, |
|
| 1266 | + 'show_option_none' => false, |
|
| 1267 | + 'class' => 'wpinv-tax-country', |
|
| 1268 | + 'chosen' => false, |
|
| 1269 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1270 | + ) ); |
|
| 1271 | + ?> |
|
| 1272 | 1272 | </td> |
| 1273 | 1273 | <td class="wpinv_tax_state"> |
| 1274 | 1274 | <?php |
| 1275 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1276 | - if( !empty( $states ) ) { |
|
| 1277 | - echo wpinv_html_select( array( |
|
| 1278 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1279 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1275 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1276 | + if( !empty( $states ) ) { |
|
| 1277 | + echo wpinv_html_select( array( |
|
| 1278 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1279 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1280 | 1280 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1281 | - 'selected' => $rate['state'], |
|
| 1282 | - 'show_option_all' => false, |
|
| 1283 | - 'show_option_none' => false, |
|
| 1284 | - 'chosen' => false, |
|
| 1285 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1286 | - ) ); |
|
| 1287 | - } else { |
|
| 1288 | - echo wpinv_html_text( array( |
|
| 1289 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1290 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1281 | + 'selected' => $rate['state'], |
|
| 1282 | + 'show_option_all' => false, |
|
| 1283 | + 'show_option_none' => false, |
|
| 1284 | + 'chosen' => false, |
|
| 1285 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1286 | + ) ); |
|
| 1287 | + } else { |
|
| 1288 | + echo wpinv_html_text( array( |
|
| 1289 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1290 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1291 | 1291 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1292 | - ) ); |
|
| 1293 | - } |
|
| 1294 | - ?> |
|
| 1292 | + ) ); |
|
| 1293 | + } |
|
| 1294 | + ?> |
|
| 1295 | 1295 | </td> |
| 1296 | 1296 | <td class="wpinv_tax_global"> |
| 1297 | 1297 | <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
@@ -1306,20 +1306,20 @@ discard block |
||
| 1306 | 1306 | <tr> |
| 1307 | 1307 | <td class="wpinv_tax_country"> |
| 1308 | 1308 | <?php |
| 1309 | - echo wpinv_html_select( array( |
|
| 1310 | - 'options' => wpinv_get_country_list( true ), |
|
| 1311 | - 'name' => 'tax_rates[0][country]', |
|
| 1312 | - 'show_option_all' => false, |
|
| 1313 | - 'show_option_none' => false, |
|
| 1314 | - 'class' => 'wpinv-tax-country', |
|
| 1315 | - 'chosen' => false, |
|
| 1316 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1317 | - ) ); ?> |
|
| 1309 | + echo wpinv_html_select( array( |
|
| 1310 | + 'options' => wpinv_get_country_list( true ), |
|
| 1311 | + 'name' => 'tax_rates[0][country]', |
|
| 1312 | + 'show_option_all' => false, |
|
| 1313 | + 'show_option_none' => false, |
|
| 1314 | + 'class' => 'wpinv-tax-country', |
|
| 1315 | + 'chosen' => false, |
|
| 1316 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1317 | + ) ); ?> |
|
| 1318 | 1318 | </td> |
| 1319 | 1319 | <td class="wpinv_tax_state"> |
| 1320 | 1320 | <?php echo wpinv_html_text( array( |
| 1321 | - 'name' => 'tax_rates[0][state]' |
|
| 1322 | - ) ); ?> |
|
| 1321 | + 'name' => 'tax_rates[0][state]' |
|
| 1322 | + ) ); ?> |
|
| 1323 | 1323 | </td> |
| 1324 | 1324 | <td class="wpinv_tax_global"> |
| 1325 | 1325 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
| 1335 | 1335 | </table> |
| 1336 | 1336 | <?php |
| 1337 | - echo ob_get_clean(); |
|
| 1337 | + echo ob_get_clean(); |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | function wpinv_tools_callback($args) { |
@@ -1362,14 +1362,14 @@ discard block |
||
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | function wpinv_descriptive_text_callback( $args ) { |
| 1365 | - echo wp_kses_post( $args['desc'] ); |
|
| 1365 | + echo wp_kses_post( $args['desc'] ); |
|
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | 1368 | function wpinv_hook_callback( $args ) { |
| 1369 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1369 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | function wpinv_set_settings_cap() { |
| 1373 | - return 'manage_options'; |
|
| 1373 | + return 'manage_options'; |
|
| 1374 | 1374 | } |
| 1375 | 1375 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
@@ -912,10 +912,11 @@ discard block |
||
| 912 | 912 | |
| 913 | 913 | $checked = false; |
| 914 | 914 | |
| 915 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 916 | - $checked = true; |
|
| 917 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 918 | - $checked = true; |
|
| 915 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) { |
|
| 916 | + $checked = true; |
|
| 917 | + } elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 918 | + $checked = true; |
|
| 919 | + } |
|
| 919 | 920 | |
| 920 | 921 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
| 921 | 922 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
@@ -932,10 +933,11 @@ discard block |
||
| 932 | 933 | foreach ( $args['options'] as $key => $option ) : |
| 933 | 934 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 934 | 935 | |
| 935 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
| 936 | - $enabled = '1'; |
|
| 937 | - else |
|
| 938 | - $enabled = null; |
|
| 936 | + if ( isset( $wpinv_options['gateways'][ $key ] ) ) { |
|
| 937 | + $enabled = '1'; |
|
| 938 | + } else { |
|
| 939 | + $enabled = null; |
|
| 940 | + } |
|
| 939 | 941 | |
| 940 | 942 | echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
| 941 | 943 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
@@ -1302,7 +1304,8 @@ discard block |
||
| 1302 | 1304 | <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
| 1303 | 1305 | </tr> |
| 1304 | 1306 | <?php endforeach; ?> |
| 1305 | - <?php else : ?> |
|
| 1307 | + <?php else { |
|
| 1308 | + : ?> |
|
| 1306 | 1309 | <tr> |
| 1307 | 1310 | <td class="wpinv_tax_country"> |
| 1308 | 1311 | <?php |
@@ -1314,7 +1317,9 @@ discard block |
||
| 1314 | 1317 | 'class' => 'wpinv-tax-country', |
| 1315 | 1318 | 'chosen' => false, |
| 1316 | 1319 | 'placeholder' => __( 'Choose a country', 'invoicing' ) |
| 1317 | - ) ); ?> |
|
| 1320 | + ) ); |
|
| 1321 | +} |
|
| 1322 | +?> |
|
| 1318 | 1323 | </td> |
| 1319 | 1324 | <td class="wpinv_tax_state"> |
| 1320 | 1325 | <?php echo wpinv_html_text( array( |
@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
| 7 | +function wpinv_get_option($key = '', $default = false) { |
|
| 8 | 8 | global $wpinv_options; |
| 9 | 9 | |
| 10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
| 11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
| 10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
| 11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
| 12 | 12 | |
| 13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
| 13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
| 16 | +function wpinv_update_option($key = '', $value = false) { |
|
| 17 | 17 | // If no key, exit |
| 18 | - if ( empty( $key ) ) { |
|
| 18 | + if (empty($key)) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if ( empty( $value ) ) { |
|
| 23 | - $remove_option = wpinv_delete_option( $key ); |
|
| 22 | + if (empty($value)) { |
|
| 23 | + $remove_option = wpinv_delete_option($key); |
|
| 24 | 24 | return $remove_option; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // First let's grab the current settings |
| 28 | - $options = get_option( 'wpinv_settings' ); |
|
| 28 | + $options = get_option('wpinv_settings'); |
|
| 29 | 29 | |
| 30 | 30 | // Let's let devs alter that value coming in |
| 31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
| 31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
| 32 | 32 | |
| 33 | 33 | // Next let's try to update the value |
| 34 | - $options[ $key ] = $value; |
|
| 35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 34 | + $options[$key] = $value; |
|
| 35 | + $did_update = update_option('wpinv_settings', $options); |
|
| 36 | 36 | |
| 37 | 37 | // If it updated, let's update the global variable |
| 38 | - if ( $did_update ) { |
|
| 38 | + if ($did_update) { |
|
| 39 | 39 | global $wpinv_options; |
| 40 | - $wpinv_options[ $key ] = $value; |
|
| 40 | + $wpinv_options[$key] = $value; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return $did_update; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -function wpinv_delete_option( $key = '' ) { |
|
| 46 | +function wpinv_delete_option($key = '') { |
|
| 47 | 47 | // If no key, exit |
| 48 | - if ( empty( $key ) ) { |
|
| 48 | + if (empty($key)) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // First let's grab the current settings |
| 53 | - $options = get_option( 'wpinv_settings' ); |
|
| 53 | + $options = get_option('wpinv_settings'); |
|
| 54 | 54 | |
| 55 | 55 | // Next let's try to update the value |
| 56 | - if( isset( $options[ $key ] ) ) { |
|
| 57 | - unset( $options[ $key ] ); |
|
| 56 | + if (isset($options[$key])) { |
|
| 57 | + unset($options[$key]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 60 | + $did_update = update_option('wpinv_settings', $options); |
|
| 61 | 61 | |
| 62 | 62 | // If it updated, let's update the global variable |
| 63 | - if ( $did_update ){ |
|
| 63 | + if ($did_update) { |
|
| 64 | 64 | global $wpinv_options; |
| 65 | 65 | $wpinv_options = $options; |
| 66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function wpinv_get_settings() { |
| 72 | - $settings = get_option( 'wpinv_settings' ); |
|
| 72 | + $settings = get_option('wpinv_settings'); |
|
| 73 | 73 | |
| 74 | - if ( empty( $settings ) ) { |
|
| 74 | + if (empty($settings)) { |
|
| 75 | 75 | // Update old settings with new single option |
| 76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
| 77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
| 78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
| 79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
| 80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
| 81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
| 76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
| 77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
| 78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
| 79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
| 80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
| 81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
| 82 | 82 | |
| 83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
| 83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
| 84 | 84 | |
| 85 | - update_option( 'wpinv_settings', $settings ); |
|
| 85 | + update_option('wpinv_settings', $settings); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
| 88 | + return apply_filters('wpinv_get_settings', $settings); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function wpinv_register_settings() { |
| 92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
| 93 | - add_option( 'wpinv_settings' ); |
|
| 92 | + if (false == get_option('wpinv_settings')) { |
|
| 93 | + add_option('wpinv_settings'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $register_settings = wpinv_get_registered_settings(); |
| 97 | 97 | |
| 98 | - foreach ( $register_settings as $tab => $sections ) { |
|
| 99 | - foreach ( $sections as $section => $settings) { |
|
| 98 | + foreach ($register_settings as $tab => $sections) { |
|
| 99 | + foreach ($sections as $section => $settings) { |
|
| 100 | 100 | // Check for backwards compatibility |
| 101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
| 102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
| 101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
| 102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
| 103 | 103 | $section = 'main'; |
| 104 | 104 | $settings = $sections; |
| 105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
| 111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - foreach ( $settings as $option ) { |
|
| 114 | + foreach ($settings as $option) { |
|
| 115 | 115 | // For backwards compatibility |
| 116 | - if ( empty( $option['id'] ) ) { |
|
| 116 | + if (empty($option['id'])) { |
|
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
| 120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
| 121 | 121 | |
| 122 | 122 | add_settings_field( |
| 123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
| 124 | 124 | $name, |
| 125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
| 127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
| 128 | 128 | array( |
| 129 | 129 | 'section' => $section, |
| 130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
| 131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
| 132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
| 133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
| 138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
| 139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
| 140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
| 141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
| 147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
| 148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
| 131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
| 132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
| 133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
| 138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
| 139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
| 140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
| 141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
| 146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
| 147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
| 148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 150 | 150 | ) |
| 151 | 151 | ); |
| 152 | 152 | } |
@@ -154,21 +154,21 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Creates our settings in the options table |
| 157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
| 157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
| 158 | 158 | } |
| 159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
| 159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
| 160 | 160 | |
| 161 | 161 | function wpinv_get_registered_settings() { |
| 162 | - $pages = wpinv_get_pages( true ); |
|
| 162 | + $pages = wpinv_get_pages(true); |
|
| 163 | 163 | |
| 164 | 164 | $due_payment_options = array(); |
| 165 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
| 166 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
| 165 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
| 166 | + for ($i = 1; $i <= 30; $i++) { |
|
| 167 | 167 | $due_payment_options[$i] = $i; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $invoice_number_padd_options = array(); |
| 171 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
| 171 | + for ($i = 0; $i <= 20; $i++) { |
|
| 172 | 172 | $invoice_number_padd_options[$i] = $i; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -177,141 +177,141 @@ discard block |
||
| 177 | 177 | $alert_wrapper_start = '<p style="color: #F00">'; |
| 178 | 178 | $alert_wrapper_close = '</p>'; |
| 179 | 179 | $wpinv_settings = array( |
| 180 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
| 180 | + 'general' => apply_filters('wpinv_settings_general', |
|
| 181 | 181 | array( |
| 182 | 182 | 'main' => array( |
| 183 | 183 | 'location_settings' => array( |
| 184 | 184 | 'id' => 'location_settings', |
| 185 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
| 185 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
| 186 | 186 | 'desc' => '', |
| 187 | 187 | 'type' => 'header', |
| 188 | 188 | ), |
| 189 | 189 | 'default_country' => array( |
| 190 | 190 | 'id' => 'default_country', |
| 191 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
| 192 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
| 191 | + 'name' => __('Default Country', 'invoicing'), |
|
| 192 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
| 193 | 193 | 'type' => 'select', |
| 194 | 194 | 'options' => wpinv_get_country_list(), |
| 195 | 195 | 'std' => 'GB', |
| 196 | 196 | 'chosen' => true, |
| 197 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
| 197 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
| 198 | 198 | ), |
| 199 | 199 | 'default_state' => array( |
| 200 | 200 | 'id' => 'default_state', |
| 201 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
| 202 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
| 201 | + 'name' => __('Default State / Province', 'invoicing'), |
|
| 202 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
| 203 | 203 | 'type' => 'country_states', |
| 204 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 204 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 205 | 205 | ), |
| 206 | 206 | 'store_name' => array( |
| 207 | 207 | 'id' => 'store_name', |
| 208 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
| 209 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
| 208 | + 'name' => __('Store Name', 'invoicing'), |
|
| 209 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
| 210 | 210 | 'std' => get_option('blogname'), |
| 211 | 211 | 'type' => 'text', |
| 212 | 212 | ), |
| 213 | 213 | 'logo' => array( |
| 214 | 214 | 'id' => 'logo', |
| 215 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
| 216 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
| 215 | + 'name' => __('Logo URL', 'invoicing'), |
|
| 216 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
| 217 | 217 | 'type' => 'text', |
| 218 | 218 | ), |
| 219 | 219 | 'store_address' => array( |
| 220 | 220 | 'id' => 'store_address', |
| 221 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
| 222 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
| 221 | + 'name' => __('Store Address', 'invoicing'), |
|
| 222 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
| 223 | 223 | 'type' => 'textarea', |
| 224 | 224 | ), |
| 225 | 225 | 'page_settings' => array( |
| 226 | 226 | 'id' => 'page_settings', |
| 227 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
| 227 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
| 228 | 228 | 'desc' => '', |
| 229 | 229 | 'type' => 'header', |
| 230 | 230 | ), |
| 231 | 231 | 'checkout_page' => array( |
| 232 | 232 | 'id' => 'checkout_page', |
| 233 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
| 234 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
| 233 | + 'name' => __('Checkout Page', 'invoicing'), |
|
| 234 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
| 235 | 235 | 'type' => 'select', |
| 236 | 236 | 'options' => $pages, |
| 237 | 237 | 'chosen' => true, |
| 238 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 238 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 239 | 239 | ), |
| 240 | 240 | 'success_page' => array( |
| 241 | 241 | 'id' => 'success_page', |
| 242 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
| 243 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
| 242 | + 'name' => __('Success Page', 'invoicing'), |
|
| 243 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
| 244 | 244 | 'type' => 'select', |
| 245 | 245 | 'options' => $pages, |
| 246 | 246 | 'chosen' => true, |
| 247 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 247 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 248 | 248 | ), |
| 249 | 249 | 'failure_page' => array( |
| 250 | 250 | 'id' => 'failure_page', |
| 251 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
| 252 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ), |
|
| 251 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
| 252 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'), |
|
| 253 | 253 | 'type' => 'select', |
| 254 | 254 | 'options' => $pages, |
| 255 | 255 | 'chosen' => true, |
| 256 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 256 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 257 | 257 | ), |
| 258 | 258 | 'invoice_history_page' => array( |
| 259 | 259 | 'id' => 'invoice_history_page', |
| 260 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
| 261 | - 'desc' => __( 'This page shows a invoice history for the current user', 'invoicing' ), |
|
| 260 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
| 261 | + 'desc' => __('This page shows a invoice history for the current user', 'invoicing'), |
|
| 262 | 262 | 'type' => 'select', |
| 263 | 263 | 'options' => $pages, |
| 264 | 264 | 'chosen' => true, |
| 265 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 265 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 266 | 266 | ) |
| 267 | 267 | ), |
| 268 | 268 | 'currency_section' => array( |
| 269 | 269 | 'currency_settings' => array( |
| 270 | 270 | 'id' => 'currency_settings', |
| 271 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
| 271 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
| 272 | 272 | 'desc' => '', |
| 273 | 273 | 'type' => 'header', |
| 274 | 274 | ), |
| 275 | 275 | 'currency' => array( |
| 276 | 276 | 'id' => 'currency', |
| 277 | - 'name' => __( 'Currency', 'invoicing' ), |
|
| 278 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
| 277 | + 'name' => __('Currency', 'invoicing'), |
|
| 278 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
| 279 | 279 | 'type' => 'select', |
| 280 | 280 | 'options' => wpinv_get_currencies(), |
| 281 | 281 | 'chosen' => true, |
| 282 | 282 | ), |
| 283 | 283 | 'currency_position' => array( |
| 284 | 284 | 'id' => 'currency_position', |
| 285 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
| 286 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
| 285 | + 'name' => __('Currency Position', 'invoicing'), |
|
| 286 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
| 287 | 287 | 'type' => 'select', |
| 288 | 288 | 'options' => array( |
| 289 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
| 290 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
| 291 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
| 292 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
| 289 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
| 290 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
| 291 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
| 292 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
| 293 | 293 | ) |
| 294 | 294 | ), |
| 295 | 295 | 'thousands_separator' => array( |
| 296 | 296 | 'id' => 'thousands_separator', |
| 297 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
| 298 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
| 297 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
| 298 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
| 299 | 299 | 'type' => 'text', |
| 300 | 300 | 'size' => 'small', |
| 301 | 301 | 'std' => ',', |
| 302 | 302 | ), |
| 303 | 303 | 'decimal_separator' => array( |
| 304 | 304 | 'id' => 'decimal_separator', |
| 305 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
| 306 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
| 305 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
| 306 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
| 307 | 307 | 'type' => 'text', |
| 308 | 308 | 'size' => 'small', |
| 309 | 309 | 'std' => '.', |
| 310 | 310 | ), |
| 311 | 311 | 'decimals' => array( |
| 312 | 312 | 'id' => 'decimals', |
| 313 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
| 314 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
| 313 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
| 314 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
| 315 | 315 | 'type' => 'number', |
| 316 | 316 | 'size' => 'small', |
| 317 | 317 | 'std' => '2', |
@@ -323,29 +323,29 @@ discard block |
||
| 323 | 323 | 'labels' => array( |
| 324 | 324 | 'labels' => array( |
| 325 | 325 | 'id' => 'labels_settings', |
| 326 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
| 326 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
| 327 | 327 | 'desc' => '', |
| 328 | 328 | 'type' => 'header', |
| 329 | 329 | ), |
| 330 | 330 | 'vat_name' => array( |
| 331 | 331 | 'id' => 'vat_name', |
| 332 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
| 333 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
| 332 | + 'name' => __('VAT Name', 'invoicing'), |
|
| 333 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
| 334 | 334 | 'type' => 'text', |
| 335 | 335 | 'size' => 'regular', |
| 336 | 336 | 'std' => 'VAT' |
| 337 | 337 | ), |
| 338 | 338 | 'vat_invoice_notice_label' => array( |
| 339 | 339 | 'id' => 'vat_invoice_notice_label', |
| 340 | - 'name' => __( 'Invoice notice label', 'invoicing' ), |
|
| 341 | - 'desc' => __( 'Use this to add a invoice notice section (label) to your invoices', 'invoicing' ), |
|
| 340 | + 'name' => __('Invoice notice label', 'invoicing'), |
|
| 341 | + 'desc' => __('Use this to add a invoice notice section (label) to your invoices', 'invoicing'), |
|
| 342 | 342 | 'type' => 'text', |
| 343 | 343 | 'size' => 'regular', |
| 344 | 344 | ), |
| 345 | 345 | 'vat_invoice_notice' => array( |
| 346 | 346 | 'id' => 'vat_invoice_notice', |
| 347 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
| 348 | - 'desc' => __( 'Use this to add a invoice notice section (description) to your invoices', 'invoicing' ), |
|
| 347 | + 'name' => __('Invoice notice', 'invoicing'), |
|
| 348 | + 'desc' => __('Use this to add a invoice notice section (description) to your invoices', 'invoicing'), |
|
| 349 | 349 | 'type' => 'text', |
| 350 | 350 | 'size' => 'regular', |
| 351 | 351 | ) |
@@ -357,22 +357,22 @@ discard block |
||
| 357 | 357 | 'main' => array( |
| 358 | 358 | 'gateway_settings' => array( |
| 359 | 359 | 'id' => 'api_header', |
| 360 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
| 360 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
| 361 | 361 | 'desc' => '', |
| 362 | 362 | 'type' => 'header', |
| 363 | 363 | ), |
| 364 | 364 | 'gateways' => array( |
| 365 | 365 | 'id' => 'gateways', |
| 366 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 367 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
| 366 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
| 367 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
| 368 | 368 | 'type' => 'gateways', |
| 369 | 369 | 'std' => array('manual'=>1), |
| 370 | 370 | 'options' => wpinv_get_payment_gateways(), |
| 371 | 371 | ), |
| 372 | 372 | 'default_gateway' => array( |
| 373 | 373 | 'id' => 'default_gateway', |
| 374 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
| 375 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
| 374 | + 'name' => __('Default Gateway', 'invoicing'), |
|
| 375 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
| 376 | 376 | 'type' => 'gateway_select', |
| 377 | 377 | 'std' => 'manual', |
| 378 | 378 | 'options' => wpinv_get_payment_gateways(), |
@@ -386,19 +386,19 @@ discard block |
||
| 386 | 386 | 'main' => array( |
| 387 | 387 | 'tax_settings' => array( |
| 388 | 388 | 'id' => 'tax_settings', |
| 389 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
| 389 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
| 390 | 390 | 'type' => 'header', |
| 391 | 391 | ), |
| 392 | 392 | 'enable_taxes' => array( |
| 393 | 393 | 'id' => 'enable_taxes', |
| 394 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
| 395 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
| 394 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
| 395 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
| 396 | 396 | 'type' => 'checkbox', |
| 397 | 397 | ), |
| 398 | 398 | 'tax_rate' => array( |
| 399 | 399 | 'id' => 'tax_rate', |
| 400 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
| 401 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
| 400 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
| 401 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
| 402 | 402 | 'type' => 'number', |
| 403 | 403 | 'size' => 'small', |
| 404 | 404 | 'min' => '0', |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | 'rates' => array( |
| 411 | 411 | 'tax_rates' => array( |
| 412 | 412 | 'id' => 'tax_rates', |
| 413 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
| 414 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
| 413 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
| 414 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
| 415 | 415 | 'type' => 'tax_rates', |
| 416 | 416 | ), |
| 417 | 417 | ) |
@@ -423,62 +423,62 @@ discard block |
||
| 423 | 423 | 'main' => array( |
| 424 | 424 | 'email_settings_header' => array( |
| 425 | 425 | 'id' => 'email_settings_header', |
| 426 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
| 426 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
| 427 | 427 | 'type' => 'header', |
| 428 | 428 | ), |
| 429 | 429 | 'email_from_name' => array( |
| 430 | 430 | 'id' => 'email_from_name', |
| 431 | - 'name' => __( 'From Name', 'invoicing' ), |
|
| 432 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
| 433 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
| 431 | + 'name' => __('From Name', 'invoicing'), |
|
| 432 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
| 433 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
| 434 | 434 | 'type' => 'text', |
| 435 | 435 | ), |
| 436 | 436 | 'email_from' => array( |
| 437 | 437 | 'id' => 'email_from', |
| 438 | - 'name' => __( 'From Email', 'invoicing' ), |
|
| 439 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
| 440 | - 'std' => get_option( 'admin_email' ), |
|
| 438 | + 'name' => __('From Email', 'invoicing'), |
|
| 439 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
| 440 | + 'std' => get_option('admin_email'), |
|
| 441 | 441 | 'type' => 'text', |
| 442 | 442 | ), |
| 443 | 443 | 'overdue_settings_header' => array( |
| 444 | 444 | 'id' => 'overdue_settings_header', |
| 445 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
| 445 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
| 446 | 446 | 'type' => 'header', |
| 447 | 447 | ), |
| 448 | 448 | 'overdue_active' => array( |
| 449 | 449 | 'id' => 'overdue_active', |
| 450 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
| 451 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
| 450 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
| 451 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
| 452 | 452 | 'type' => 'checkbox', |
| 453 | 453 | 'std' => false, |
| 454 | 454 | ), |
| 455 | 455 | 'overdue_days' => array( |
| 456 | 456 | 'id' => 'overdue_days', |
| 457 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
| 458 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
| 457 | + 'name' => __('Default Due Date', 'invoicing'), |
|
| 458 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
| 459 | 459 | 'type' => 'select', |
| 460 | 460 | 'options' => $due_payment_options, |
| 461 | 461 | 'chosen' => true, |
| 462 | 462 | 'std' => 0, |
| 463 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 463 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 464 | 464 | ), |
| 465 | 465 | 'email_template_header' => array( |
| 466 | 466 | 'id' => 'email_template_header', |
| 467 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
| 467 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
| 468 | 468 | 'type' => 'header', |
| 469 | 469 | ), |
| 470 | 470 | 'email_header_image' => array( |
| 471 | 471 | 'id' => 'email_header_image', |
| 472 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
| 473 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
| 472 | + 'name' => __('Header Image', 'invoicing'), |
|
| 473 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
| 474 | 474 | 'std' => '', |
| 475 | 475 | 'type' => 'text', |
| 476 | 476 | ), |
| 477 | 477 | 'email_footer_text' => array( |
| 478 | 478 | 'id' => 'email_footer_text', |
| 479 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
| 480 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
| 481 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
| 479 | + 'name' => __('Footer Text', 'invoicing'), |
|
| 480 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
| 481 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
| 482 | 482 | 'type' => 'textarea', |
| 483 | 483 | 'class' => 'regular-text', |
| 484 | 484 | 'rows' => 2, |
@@ -486,29 +486,29 @@ discard block |
||
| 486 | 486 | ), |
| 487 | 487 | 'email_base_color' => array( |
| 488 | 488 | 'id' => 'email_base_color', |
| 489 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
| 490 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
| 489 | + 'name' => __('Base Color', 'invoicing'), |
|
| 490 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
| 491 | 491 | 'std' => '#557da2', |
| 492 | 492 | 'type' => 'color', |
| 493 | 493 | ), |
| 494 | 494 | 'email_background_color' => array( |
| 495 | 495 | 'id' => 'email_background_color', |
| 496 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
| 497 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
| 496 | + 'name' => __('Background Color', 'invoicing'), |
|
| 497 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
| 498 | 498 | 'std' => '#f5f5f5', |
| 499 | 499 | 'type' => 'color', |
| 500 | 500 | ), |
| 501 | 501 | 'email_body_background_color' => array( |
| 502 | 502 | 'id' => 'email_body_background_color', |
| 503 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
| 504 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
| 503 | + 'name' => __('Body Background Color', 'invoicing'), |
|
| 504 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
| 505 | 505 | 'std' => '#fdfdfd', |
| 506 | 506 | 'type' => 'color', |
| 507 | 507 | ), |
| 508 | 508 | 'email_text_color' => array( |
| 509 | 509 | 'id' => 'email_text_color', |
| 510 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
| 511 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
| 510 | + 'name' => __('Body Text Color', 'invoicing'), |
|
| 511 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
| 512 | 512 | 'std' => '#505050', |
| 513 | 513 | 'type' => 'color', |
| 514 | 514 | ), |
@@ -527,25 +527,25 @@ discard block |
||
| 527 | 527 | 'main' => array( |
| 528 | 528 | 'fields_settings' => array( |
| 529 | 529 | 'id' => 'fields_settings', |
| 530 | - 'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>', |
|
| 530 | + 'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>', |
|
| 531 | 531 | 'type' => 'header', |
| 532 | 532 | ), |
| 533 | 533 | 'phone_mandatory' => array( |
| 534 | 534 | 'id' => 'phone_mandatory', |
| 535 | - 'name' => __( 'Phone No. Mandatory?', 'invoicing' ), |
|
| 536 | - 'desc' => __( 'Tick this to make phone number mandatory in invoice address fields.', 'invoicing' ), |
|
| 535 | + 'name' => __('Phone No. Mandatory?', 'invoicing'), |
|
| 536 | + 'desc' => __('Tick this to make phone number mandatory in invoice address fields.', 'invoicing'), |
|
| 537 | 537 | 'type' => 'checkbox', |
| 538 | 538 | 'std' => true, |
| 539 | 539 | ), |
| 540 | 540 | 'invoice_number_format_settings' => array( |
| 541 | 541 | 'id' => 'invoice_number_format_settings', |
| 542 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
| 542 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
| 543 | 543 | 'type' => 'header', |
| 544 | 544 | ), |
| 545 | 545 | 'invoice_number_padd' => array( |
| 546 | 546 | 'id' => 'invoice_number_padd', |
| 547 | - 'name' => __( 'Minimum digits', 'invoicing' ), |
|
| 548 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
| 547 | + 'name' => __('Minimum digits', 'invoicing'), |
|
| 548 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
| 549 | 549 | 'type' => 'select', |
| 550 | 550 | 'options' => $invoice_number_padd_options, |
| 551 | 551 | 'std' => 5, |
@@ -553,8 +553,8 @@ discard block |
||
| 553 | 553 | ), |
| 554 | 554 | 'invoice_number_prefix' => array( |
| 555 | 555 | 'id' => 'invoice_number_prefix', |
| 556 | - 'name' => __( 'Invoice Number prefix', 'invoicing' ), |
|
| 557 | - 'desc' => __( 'A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
| 556 | + 'name' => __('Invoice Number prefix', 'invoicing'), |
|
| 557 | + 'desc' => __('A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
| 558 | 558 | 'type' => 'text', |
| 559 | 559 | 'size' => 'regular', |
| 560 | 560 | 'std' => 'WPINV-', |
@@ -562,25 +562,25 @@ discard block |
||
| 562 | 562 | ), |
| 563 | 563 | 'invoice_number_postfix' => array( |
| 564 | 564 | 'id' => 'invoice_number_postfix', |
| 565 | - 'name' => __( 'Invoice Number postfix', 'invoicing' ), |
|
| 566 | - 'desc' => __( 'A postfix to append to all invoice numbers.', 'invoicing' ), |
|
| 565 | + 'name' => __('Invoice Number postfix', 'invoicing'), |
|
| 566 | + 'desc' => __('A postfix to append to all invoice numbers.', 'invoicing'), |
|
| 567 | 567 | 'type' => 'text', |
| 568 | 568 | 'size' => 'regular', |
| 569 | 569 | 'std' => '' |
| 570 | 570 | ), |
| 571 | 571 | 'guest_checkout_settings' => array( |
| 572 | 572 | 'id' => 'guest_checkout_settings', |
| 573 | - 'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>', |
|
| 573 | + 'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>', |
|
| 574 | 574 | 'type' => 'header', |
| 575 | 575 | ), |
| 576 | 576 | 'guest_checkout' => array( |
| 577 | 577 | 'type' => 'radio', |
| 578 | 578 | 'id' => 'guest_checkout', |
| 579 | - 'name' => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ), |
|
| 580 | - 'desc' => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing' ), |
|
| 579 | + 'name' => __('Pay via Invoice Link for non logged in user', 'invoicing'), |
|
| 580 | + 'desc' => __('Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing'), |
|
| 581 | 581 | 'options' => array( |
| 582 | - 0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ), |
|
| 583 | - 1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ), |
|
| 582 | + 0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'), |
|
| 583 | + 1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'), |
|
| 584 | 584 | ), |
| 585 | 585 | 'std' => 0, |
| 586 | 586 | ), |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | 'main' => array( |
| 594 | 594 | 'tool_settings' => array( |
| 595 | 595 | 'id' => 'tool_settings', |
| 596 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
| 597 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
| 596 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
| 597 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
| 598 | 598 | 'type' => 'tools', |
| 599 | 599 | ), |
| 600 | 600 | ), |
@@ -602,135 +602,135 @@ discard block |
||
| 602 | 602 | ) |
| 603 | 603 | ); |
| 604 | 604 | |
| 605 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
| 605 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 608 | +function wpinv_settings_sanitize($input = array()) { |
|
| 609 | 609 | global $wpinv_options; |
| 610 | 610 | |
| 611 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
| 611 | + if (empty($_POST['_wp_http_referer'])) { |
|
| 612 | 612 | return $input; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
| 615 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
| 616 | 616 | |
| 617 | 617 | $settings = wpinv_get_registered_settings(); |
| 618 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 619 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 618 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 619 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 620 | 620 | |
| 621 | 621 | $input = $input ? $input : array(); |
| 622 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 623 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 622 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 623 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 624 | 624 | |
| 625 | 625 | // Loop through each setting being saved and pass it through a sanitization filter |
| 626 | - foreach ( $input as $key => $value ) { |
|
| 626 | + foreach ($input as $key => $value) { |
|
| 627 | 627 | // Get the setting type (checkbox, select, etc) |
| 628 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
| 628 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
| 629 | 629 | |
| 630 | - if ( $type ) { |
|
| 630 | + if ($type) { |
|
| 631 | 631 | // Field type specific filter |
| 632 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
| 632 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | // General filter |
| 636 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 636 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 640 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 641 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 640 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 641 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 642 | 642 | |
| 643 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 643 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 644 | 644 | |
| 645 | - if ( ! empty( $found_settings ) ) { |
|
| 646 | - foreach ( $found_settings as $key => $value ) { |
|
| 645 | + if (!empty($found_settings)) { |
|
| 646 | + foreach ($found_settings as $key => $value) { |
|
| 647 | 647 | |
| 648 | 648 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 649 | - if ( is_numeric( $key ) ) { |
|
| 649 | + if (is_numeric($key)) { |
|
| 650 | 650 | $key = $value['id']; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - if ( empty( $input[ $key ] ) ) { |
|
| 654 | - unset( $wpinv_options[ $key ] ); |
|
| 653 | + if (empty($input[$key])) { |
|
| 654 | + unset($wpinv_options[$key]); |
|
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | // Merge our new settings with the existing |
| 660 | - $output = array_merge( $wpinv_options, $input ); |
|
| 660 | + $output = array_merge($wpinv_options, $input); |
|
| 661 | 661 | |
| 662 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 662 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 663 | 663 | |
| 664 | 664 | return $output; |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
| 667 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
| 668 | 668 | global $wpinv_options, $wpi_session; |
| 669 | 669 | |
| 670 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 670 | + if (!current_user_can('manage_options')) { |
|
| 671 | 671 | return $input; |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
| 674 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
| 675 | 675 | // Shows an admin notice about upgrading previous order numbers |
| 676 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
| 676 | + $wpi_session->set('upgrade_sequential', '1'); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | return $input; |
| 680 | 680 | } |
| 681 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
| 681 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
| 682 | 682 | |
| 683 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 684 | - if( !current_user_can( 'manage_options' ) ) { |
|
| 683 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 684 | + if (!current_user_can('manage_options')) { |
|
| 685 | 685 | return $input; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
| 688 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
| 689 | 689 | |
| 690 | 690 | $tax_rates = array(); |
| 691 | 691 | |
| 692 | - if ( !empty( $new_rates ) ) { |
|
| 693 | - foreach ( $new_rates as $rate ) { |
|
| 694 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
| 692 | + if (!empty($new_rates)) { |
|
| 693 | + foreach ($new_rates as $rate) { |
|
| 694 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
| 695 | 695 | continue; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
| 698 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
| 699 | 699 | |
| 700 | 700 | $tax_rates[] = $rate; |
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 704 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 705 | 705 | |
| 706 | 706 | return $input; |
| 707 | 707 | } |
| 708 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 708 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 709 | 709 | |
| 710 | -function wpinv_sanitize_text_field( $input ) { |
|
| 711 | - return trim( $input ); |
|
| 710 | +function wpinv_sanitize_text_field($input) { |
|
| 711 | + return trim($input); |
|
| 712 | 712 | } |
| 713 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
| 713 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
| 714 | 714 | |
| 715 | 715 | function wpinv_get_settings_tabs() { |
| 716 | 716 | $tabs = array(); |
| 717 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 718 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 719 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 720 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 721 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 722 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 723 | - |
|
| 724 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 717 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 718 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 719 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 720 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 721 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 722 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 723 | + |
|
| 724 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 727 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 728 | 728 | $tabs = false; |
| 729 | 729 | $sections = wpinv_get_registered_settings_sections(); |
| 730 | 730 | |
| 731 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 732 | - $tabs = $sections[ $tab ]; |
|
| 733 | - } else if ( $tab ) { |
|
| 731 | + if ($tab && !empty($sections[$tab])) { |
|
| 732 | + $tabs = $sections[$tab]; |
|
| 733 | + } else if ($tab) { |
|
| 734 | 734 | $tabs = false; |
| 735 | 735 | } |
| 736 | 736 | |
@@ -740,135 +740,135 @@ discard block |
||
| 740 | 740 | function wpinv_get_registered_settings_sections() { |
| 741 | 741 | static $sections = false; |
| 742 | 742 | |
| 743 | - if ( false !== $sections ) { |
|
| 743 | + if (false !== $sections) { |
|
| 744 | 744 | return $sections; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | $sections = array( |
| 748 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
| 749 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 750 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 751 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 752 | - ) ), |
|
| 753 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
| 754 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 755 | - ) ), |
|
| 756 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
| 757 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 758 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 759 | - ) ), |
|
| 760 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
| 761 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 762 | - ) ), |
|
| 763 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
| 764 | - 'main' => __( 'Misc Settings', 'invoicing' ), |
|
| 765 | - ) ), |
|
| 766 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
| 767 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 768 | - ) ), |
|
| 748 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
| 749 | + 'main' => __('General Settings', 'invoicing'), |
|
| 750 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 751 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 752 | + )), |
|
| 753 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
| 754 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 755 | + )), |
|
| 756 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
| 757 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 758 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 759 | + )), |
|
| 760 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
| 761 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 762 | + )), |
|
| 763 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
| 764 | + 'main' => __('Misc Settings', 'invoicing'), |
|
| 765 | + )), |
|
| 766 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
| 767 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 768 | + )), |
|
| 769 | 769 | ); |
| 770 | 770 | |
| 771 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 771 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 772 | 772 | |
| 773 | 773 | return $sections; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
| 776 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
| 777 | 777 | $pages_options = array(); |
| 778 | 778 | |
| 779 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 780 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 779 | + if ($default_label !== NULL && $default_label !== false) { |
|
| 780 | + $pages_options = array('' => $default_label); // Blank option |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | $pages = get_pages(); |
| 784 | - if ( $pages ) { |
|
| 785 | - foreach ( $pages as $page ) { |
|
| 784 | + if ($pages) { |
|
| 785 | + foreach ($pages as $page) { |
|
| 786 | 786 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 787 | - $pages_options[ $page->ID ] = $title; |
|
| 787 | + $pages_options[$page->ID] = $title; |
|
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | return $pages_options; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | -function wpinv_header_callback( $args ) { |
|
| 795 | - if ( !empty( $args['desc'] ) ) { |
|
| 794 | +function wpinv_header_callback($args) { |
|
| 795 | + if (!empty($args['desc'])) { |
|
| 796 | 796 | echo $args['desc']; |
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | -function wpinv_hidden_callback( $args ) { |
|
| 800 | +function wpinv_hidden_callback($args) { |
|
| 801 | 801 | global $wpinv_options; |
| 802 | 802 | |
| 803 | - if ( isset( $args['set_value'] ) ) { |
|
| 803 | + if (isset($args['set_value'])) { |
|
| 804 | 804 | $value = $args['set_value']; |
| 805 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 806 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 805 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
| 806 | + $value = $wpinv_options[$args['id']]; |
|
| 807 | 807 | } else { |
| 808 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 808 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 811 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 812 | 812 | $args['readonly'] = true; |
| 813 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 813 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 814 | 814 | $name = ''; |
| 815 | 815 | } else { |
| 816 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 816 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 819 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 820 | 820 | |
| 821 | 821 | echo $html; |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | -function wpinv_checkbox_callback( $args ) { |
|
| 824 | +function wpinv_checkbox_callback($args) { |
|
| 825 | 825 | global $wpinv_options; |
| 826 | 826 | |
| 827 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 827 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 828 | 828 | |
| 829 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 829 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 830 | 830 | $name = ''; |
| 831 | 831 | } else { |
| 832 | 832 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 835 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
| 836 | 836 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
| 837 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 837 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 838 | 838 | |
| 839 | 839 | echo $html; |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | -function wpinv_multicheck_callback( $args ) { |
|
| 842 | +function wpinv_multicheck_callback($args) { |
|
| 843 | 843 | global $wpinv_options; |
| 844 | 844 | |
| 845 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 845 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 846 | 846 | |
| 847 | - if ( ! empty( $args['options'] ) ) { |
|
| 848 | - foreach( $args['options'] as $key => $option ): |
|
| 849 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 850 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 847 | + if (!empty($args['options'])) { |
|
| 848 | + foreach ($args['options'] as $key => $option): |
|
| 849 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 850 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
| 851 | 851 | $enabled = $sanitize_key; |
| 852 | 852 | } else { |
| 853 | 853 | $enabled = NULL; |
| 854 | 854 | } |
| 855 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 856 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 855 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
| 856 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
| 857 | 857 | endforeach; |
| 858 | 858 | echo '<p class="description">' . $args['desc'] . '</p>'; |
| 859 | 859 | } |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | -function wpinv_payment_icons_callback( $args ) { |
|
| 862 | +function wpinv_payment_icons_callback($args) { |
|
| 863 | 863 | global $wpinv_options; |
| 864 | 864 | |
| 865 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 865 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 866 | 866 | |
| 867 | - if ( ! empty( $args['options'] ) ) { |
|
| 868 | - foreach( $args['options'] as $key => $option ) { |
|
| 869 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 867 | + if (!empty($args['options'])) { |
|
| 868 | + foreach ($args['options'] as $key => $option) { |
|
| 869 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 870 | 870 | |
| 871 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 871 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
| 872 | 872 | $enabled = $option; |
| 873 | 873 | } else { |
| 874 | 874 | $enabled = NULL; |
@@ -876,194 +876,194 @@ discard block |
||
| 876 | 876 | |
| 877 | 877 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 878 | 878 | |
| 879 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 879 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
| 880 | 880 | |
| 881 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 882 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 881 | + if (wpinv_string_is_image_url($key)) { |
|
| 882 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 883 | 883 | } else { |
| 884 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 884 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 885 | 885 | |
| 886 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 887 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 886 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 887 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 888 | 888 | } else { |
| 889 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 889 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 890 | 890 | $content_dir = WP_CONTENT_DIR; |
| 891 | 891 | |
| 892 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 892 | + if (function_exists('wp_normalize_path')) { |
|
| 893 | 893 | // Replaces backslashes with forward slashes for Windows systems |
| 894 | - $image = wp_normalize_path( $image ); |
|
| 895 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 894 | + $image = wp_normalize_path($image); |
|
| 895 | + $content_dir = wp_normalize_path($content_dir); |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 898 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 901 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 902 | 902 | } |
| 903 | 903 | echo $option . '</label>'; |
| 904 | 904 | } |
| 905 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 905 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 906 | 906 | } |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | -function wpinv_radio_callback( $args ) { |
|
| 909 | +function wpinv_radio_callback($args) { |
|
| 910 | 910 | global $wpinv_options; |
| 911 | 911 | |
| 912 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 912 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 913 | 913 | |
| 914 | - foreach ( $args['options'] as $key => $option ) : |
|
| 915 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 914 | + foreach ($args['options'] as $key => $option) : |
|
| 915 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 916 | 916 | |
| 917 | 917 | $checked = false; |
| 918 | 918 | |
| 919 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 919 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
| 920 | 920 | $checked = true; |
| 921 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 921 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
| 922 | 922 | $checked = true; |
| 923 | 923 | |
| 924 | 924 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
| 925 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 925 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
| 926 | 926 | endforeach; |
| 927 | 927 | |
| 928 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 928 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | -function wpinv_gateways_callback( $args ) { |
|
| 931 | +function wpinv_gateways_callback($args) { |
|
| 932 | 932 | global $wpinv_options; |
| 933 | 933 | |
| 934 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 934 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 935 | 935 | |
| 936 | - foreach ( $args['options'] as $key => $option ) : |
|
| 937 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 936 | + foreach ($args['options'] as $key => $option) : |
|
| 937 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 938 | 938 | |
| 939 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
| 939 | + if (isset($wpinv_options['gateways'][$key])) |
|
| 940 | 940 | $enabled = '1'; |
| 941 | 941 | else |
| 942 | 942 | $enabled = null; |
| 943 | 943 | |
| 944 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 945 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 944 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 945 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
| 946 | 946 | endforeach; |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | function wpinv_gateway_select_callback($args) { |
| 950 | 950 | global $wpinv_options; |
| 951 | 951 | |
| 952 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 952 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 953 | 953 | |
| 954 | 954 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
| 955 | 955 | |
| 956 | - foreach ( $args['options'] as $key => $option ) : |
|
| 957 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 958 | - $selected = selected( $key, $args['selected'], false ); |
|
| 956 | + foreach ($args['options'] as $key => $option) : |
|
| 957 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 958 | + $selected = selected($key, $args['selected'], false); |
|
| 959 | 959 | } else { |
| 960 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
| 960 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
| 961 | 961 | } |
| 962 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 962 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 963 | 963 | endforeach; |
| 964 | 964 | |
| 965 | 965 | echo '</select>'; |
| 966 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 966 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | -function wpinv_text_callback( $args ) { |
|
| 969 | +function wpinv_text_callback($args) { |
|
| 970 | 970 | global $wpinv_options; |
| 971 | 971 | |
| 972 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 972 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 973 | 973 | |
| 974 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 975 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 974 | + if (isset($wpinv_options[$args['id']])) { |
|
| 975 | + $value = $wpinv_options[$args['id']]; |
|
| 976 | 976 | } else { |
| 977 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 977 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 980 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 981 | 981 | $args['readonly'] = true; |
| 982 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 982 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 983 | 983 | $name = ''; |
| 984 | 984 | } else { |
| 985 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 985 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
| 989 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 990 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 991 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 989 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 990 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
| 991 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 992 | 992 | |
| 993 | 993 | echo $html; |
| 994 | 994 | } |
| 995 | 995 | |
| 996 | -function wpinv_number_callback( $args ) { |
|
| 996 | +function wpinv_number_callback($args) { |
|
| 997 | 997 | global $wpinv_options; |
| 998 | 998 | |
| 999 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 999 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1000 | 1000 | |
| 1001 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1002 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1001 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1002 | + $value = $wpinv_options[$args['id']]; |
|
| 1003 | 1003 | } else { |
| 1004 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1004 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1007 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1008 | 1008 | $args['readonly'] = true; |
| 1009 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1009 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1010 | 1010 | $name = ''; |
| 1011 | 1011 | } else { |
| 1012 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1012 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1016 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1017 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1015 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
| 1016 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
| 1017 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
| 1018 | 1018 | |
| 1019 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1020 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1021 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1019 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1020 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1021 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1022 | 1022 | |
| 1023 | 1023 | echo $html; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | -function wpinv_textarea_callback( $args ) { |
|
| 1026 | +function wpinv_textarea_callback($args) { |
|
| 1027 | 1027 | global $wpinv_options; |
| 1028 | 1028 | |
| 1029 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1029 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1030 | 1030 | |
| 1031 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1032 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1031 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1032 | + $value = $wpinv_options[$args['id']]; |
|
| 1033 | 1033 | } else { |
| 1034 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1034 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1038 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 1037 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1038 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 1039 | 1039 | |
| 1040 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1041 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1040 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1041 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1042 | 1042 | |
| 1043 | 1043 | echo $html; |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | -function wpinv_password_callback( $args ) { |
|
| 1046 | +function wpinv_password_callback($args) { |
|
| 1047 | 1047 | global $wpinv_options; |
| 1048 | 1048 | |
| 1049 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1049 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1050 | 1050 | |
| 1051 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1052 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1051 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1052 | + $value = $wpinv_options[$args['id']]; |
|
| 1053 | 1053 | } else { |
| 1054 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1054 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1058 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1059 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1057 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1058 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
| 1059 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1060 | 1060 | |
| 1061 | 1061 | echo $html; |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | 1064 | function wpinv_missing_callback($args) { |
| 1065 | 1065 | printf( |
| 1066 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1066 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 1067 | 1067 | '<strong>' . $args['id'] . '</strong>' |
| 1068 | 1068 | ); |
| 1069 | 1069 | } |
@@ -1071,137 +1071,137 @@ discard block |
||
| 1071 | 1071 | function wpinv_select_callback($args) { |
| 1072 | 1072 | global $wpinv_options; |
| 1073 | 1073 | |
| 1074 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1074 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1075 | 1075 | |
| 1076 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1077 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1076 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1077 | + $value = $wpinv_options[$args['id']]; |
|
| 1078 | 1078 | } else { |
| 1079 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1079 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1082 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1083 | 1083 | $value = $args['selected']; |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1086 | + if (isset($args['placeholder'])) { |
|
| 1087 | 1087 | $placeholder = $args['placeholder']; |
| 1088 | 1088 | } else { |
| 1089 | 1089 | $placeholder = ''; |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | - if ( isset( $args['chosen'] ) ) { |
|
| 1092 | + if (isset($args['chosen'])) { |
|
| 1093 | 1093 | $chosen = 'class="wpinv-chosen"'; |
| 1094 | 1094 | } else { |
| 1095 | 1095 | $chosen = ''; |
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | - if( !empty( $args['onchange'] ) ) { |
|
| 1099 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 1098 | + if (!empty($args['onchange'])) { |
|
| 1099 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 1100 | 1100 | } else { |
| 1101 | 1101 | $onchange = ''; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1104 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
| 1105 | 1105 | |
| 1106 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1107 | - $selected = selected( $option, $value, false ); |
|
| 1108 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1106 | + foreach ($args['options'] as $option => $name) { |
|
| 1107 | + $selected = selected($option, $value, false); |
|
| 1108 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | $html .= '</select>'; |
| 1112 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1112 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1113 | 1113 | |
| 1114 | 1114 | echo $html; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | -function wpinv_color_select_callback( $args ) { |
|
| 1117 | +function wpinv_color_select_callback($args) { |
|
| 1118 | 1118 | global $wpinv_options; |
| 1119 | 1119 | |
| 1120 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1120 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1121 | 1121 | |
| 1122 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1123 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1122 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1123 | + $value = $wpinv_options[$args['id']]; |
|
| 1124 | 1124 | } else { |
| 1125 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1125 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1128 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 1129 | 1129 | |
| 1130 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1131 | - $selected = selected( $option, $value, false ); |
|
| 1132 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1130 | + foreach ($args['options'] as $option => $color) { |
|
| 1131 | + $selected = selected($option, $value, false); |
|
| 1132 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | $html .= '</select>'; |
| 1136 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1136 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1137 | 1137 | |
| 1138 | 1138 | echo $html; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | -function wpinv_rich_editor_callback( $args ) { |
|
| 1141 | +function wpinv_rich_editor_callback($args) { |
|
| 1142 | 1142 | global $wpinv_options, $wp_version; |
| 1143 | 1143 | |
| 1144 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1144 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1145 | 1145 | |
| 1146 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1147 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1146 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1147 | + $value = $wpinv_options[$args['id']]; |
|
| 1148 | 1148 | |
| 1149 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1150 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1149 | + if (empty($args['allow_blank']) && empty($value)) { |
|
| 1150 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1151 | 1151 | } |
| 1152 | 1152 | } else { |
| 1153 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1153 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1156 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 1157 | 1157 | |
| 1158 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1158 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 1159 | 1159 | ob_start(); |
| 1160 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1160 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
| 1161 | 1161 | $html = ob_get_clean(); |
| 1162 | 1162 | } else { |
| 1163 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1163 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1166 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1167 | 1167 | |
| 1168 | 1168 | echo $html; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | -function wpinv_upload_callback( $args ) { |
|
| 1171 | +function wpinv_upload_callback($args) { |
|
| 1172 | 1172 | global $wpinv_options; |
| 1173 | 1173 | |
| 1174 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1174 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1175 | 1175 | |
| 1176 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1176 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1177 | 1177 | $value = $wpinv_options[$args['id']]; |
| 1178 | 1178 | } else { |
| 1179 | 1179 | $value = isset($args['std']) ? $args['std'] : ''; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1183 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1184 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1185 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1182 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1183 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1184 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 1185 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1186 | 1186 | |
| 1187 | 1187 | echo $html; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | -function wpinv_color_callback( $args ) { |
|
| 1190 | +function wpinv_color_callback($args) { |
|
| 1191 | 1191 | global $wpinv_options; |
| 1192 | 1192 | |
| 1193 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1193 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1194 | 1194 | |
| 1195 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1196 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1195 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1196 | + $value = $wpinv_options[$args['id']]; |
|
| 1197 | 1197 | } else { |
| 1198 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1198 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1201 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
| 1202 | 1202 | |
| 1203 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1204 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1203 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
| 1204 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1205 | 1205 | |
| 1206 | 1206 | echo $html; |
| 1207 | 1207 | } |
@@ -1209,9 +1209,9 @@ discard block |
||
| 1209 | 1209 | function wpinv_country_states_callback($args) { |
| 1210 | 1210 | global $wpinv_options; |
| 1211 | 1211 | |
| 1212 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1212 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1213 | 1213 | |
| 1214 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1214 | + if (isset($args['placeholder'])) { |
|
| 1215 | 1215 | $placeholder = $args['placeholder']; |
| 1216 | 1216 | } else { |
| 1217 | 1217 | $placeholder = ''; |
@@ -1219,17 +1219,17 @@ discard block |
||
| 1219 | 1219 | |
| 1220 | 1220 | $states = wpinv_get_country_states(); |
| 1221 | 1221 | |
| 1222 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1223 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1224 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1222 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
| 1223 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1224 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 1225 | 1225 | |
| 1226 | - foreach ( $states as $option => $name ) { |
|
| 1227 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1228 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1226 | + foreach ($states as $option => $name) { |
|
| 1227 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
| 1228 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | $html .= '</select>'; |
| 1232 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1232 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1233 | 1233 | |
| 1234 | 1234 | echo $html; |
| 1235 | 1235 | } |
@@ -1244,25 +1244,25 @@ discard block |
||
| 1244 | 1244 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
| 1245 | 1245 | <thead> |
| 1246 | 1246 | <tr> |
| 1247 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
| 1248 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
| 1249 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
| 1250 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
| 1251 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
| 1252 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
| 1247 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
| 1248 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
| 1249 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
| 1250 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
| 1251 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
| 1252 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
| 1253 | 1253 | </tr> |
| 1254 | 1254 | </thead> |
| 1255 | 1255 | <tbody> |
| 1256 | - <?php if( !empty( $rates ) ) : ?> |
|
| 1257 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
| 1256 | + <?php if (!empty($rates)) : ?> |
|
| 1257 | + <?php foreach ($rates as $key => $rate) : ?> |
|
| 1258 | 1258 | <?php |
| 1259 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
| 1259 | + $sanitized_key = wpinv_sanitize_key($key); |
|
| 1260 | 1260 | ?> |
| 1261 | 1261 | <tr> |
| 1262 | 1262 | <td class="wpinv_tax_country"> |
| 1263 | 1263 | <?php |
| 1264 | - echo wpinv_html_select( array( |
|
| 1265 | - 'options' => wpinv_get_country_list( true ), |
|
| 1264 | + echo wpinv_html_select(array( |
|
| 1265 | + 'options' => wpinv_get_country_list(true), |
|
| 1266 | 1266 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1267 | 1267 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1268 | 1268 | 'selected' => $rate['country'], |
@@ -1270,72 +1270,72 @@ discard block |
||
| 1270 | 1270 | 'show_option_none' => false, |
| 1271 | 1271 | 'class' => 'wpinv-tax-country', |
| 1272 | 1272 | 'chosen' => false, |
| 1273 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1274 | - ) ); |
|
| 1273 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1274 | + )); |
|
| 1275 | 1275 | ?> |
| 1276 | 1276 | </td> |
| 1277 | 1277 | <td class="wpinv_tax_state"> |
| 1278 | 1278 | <?php |
| 1279 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1280 | - if( !empty( $states ) ) { |
|
| 1281 | - echo wpinv_html_select( array( |
|
| 1282 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1279 | + $states = wpinv_get_country_states($rate['country']); |
|
| 1280 | + if (!empty($states)) { |
|
| 1281 | + echo wpinv_html_select(array( |
|
| 1282 | + 'options' => array_merge(array('' => ''), $states), |
|
| 1283 | 1283 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1284 | 1284 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1285 | 1285 | 'selected' => $rate['state'], |
| 1286 | 1286 | 'show_option_all' => false, |
| 1287 | 1287 | 'show_option_none' => false, |
| 1288 | 1288 | 'chosen' => false, |
| 1289 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1290 | - ) ); |
|
| 1289 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
| 1290 | + )); |
|
| 1291 | 1291 | } else { |
| 1292 | - echo wpinv_html_text( array( |
|
| 1292 | + echo wpinv_html_text(array( |
|
| 1293 | 1293 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
| 1294 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1294 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
| 1295 | 1295 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1296 | - ) ); |
|
| 1296 | + )); |
|
| 1297 | 1297 | } |
| 1298 | 1298 | ?> |
| 1299 | 1299 | </td> |
| 1300 | 1300 | <td class="wpinv_tax_global"> |
| 1301 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
| 1302 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1301 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
| 1302 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1303 | 1303 | </td> |
| 1304 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
| 1305 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
| 1306 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1304 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
| 1305 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
| 1306 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1307 | 1307 | </tr> |
| 1308 | 1308 | <?php endforeach; ?> |
| 1309 | 1309 | <?php else : ?> |
| 1310 | 1310 | <tr> |
| 1311 | 1311 | <td class="wpinv_tax_country"> |
| 1312 | 1312 | <?php |
| 1313 | - echo wpinv_html_select( array( |
|
| 1314 | - 'options' => wpinv_get_country_list( true ), |
|
| 1313 | + echo wpinv_html_select(array( |
|
| 1314 | + 'options' => wpinv_get_country_list(true), |
|
| 1315 | 1315 | 'name' => 'tax_rates[0][country]', |
| 1316 | 1316 | 'show_option_all' => false, |
| 1317 | 1317 | 'show_option_none' => false, |
| 1318 | 1318 | 'class' => 'wpinv-tax-country', |
| 1319 | 1319 | 'chosen' => false, |
| 1320 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1321 | - ) ); ?> |
|
| 1320 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1321 | + )); ?> |
|
| 1322 | 1322 | </td> |
| 1323 | 1323 | <td class="wpinv_tax_state"> |
| 1324 | - <?php echo wpinv_html_text( array( |
|
| 1324 | + <?php echo wpinv_html_text(array( |
|
| 1325 | 1325 | 'name' => 'tax_rates[0][state]' |
| 1326 | - ) ); ?> |
|
| 1326 | + )); ?> |
|
| 1327 | 1327 | </td> |
| 1328 | 1328 | <td class="wpinv_tax_global"> |
| 1329 | 1329 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
| 1330 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1330 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1331 | 1331 | </td> |
| 1332 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
| 1332 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
| 1333 | 1333 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
| 1334 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1334 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1335 | 1335 | </tr> |
| 1336 | 1336 | <?php endif; ?> |
| 1337 | 1337 | </tbody> |
| 1338 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
| 1338 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
| 1339 | 1339 | </table> |
| 1340 | 1340 | <?php |
| 1341 | 1341 | echo ob_get_clean(); |
@@ -1346,44 +1346,44 @@ discard block |
||
| 1346 | 1346 | ob_start(); ?> |
| 1347 | 1347 | </td><tr> |
| 1348 | 1348 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 1349 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1350 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 1349 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1350 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 1351 | 1351 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 1352 | 1352 | <thead> |
| 1353 | 1353 | <tr> |
| 1354 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 1355 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 1356 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 1354 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 1355 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 1356 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 1357 | 1357 | </tr> |
| 1358 | 1358 | </thead> |
| 1359 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1359 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1360 | 1360 | <tbody> |
| 1361 | 1361 | </tbody> |
| 1362 | 1362 | </table> |
| 1363 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1363 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1364 | 1364 | <?php |
| 1365 | 1365 | echo ob_get_clean(); |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1369 | - echo wp_kses_post( $args['desc'] ); |
|
| 1368 | +function wpinv_descriptive_text_callback($args) { |
|
| 1369 | + echo wp_kses_post($args['desc']); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | -function wpinv_hook_callback( $args ) { |
|
| 1373 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1372 | +function wpinv_hook_callback($args) { |
|
| 1373 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | function wpinv_set_settings_cap() { |
| 1377 | 1377 | return 'manage_options'; |
| 1378 | 1378 | } |
| 1379 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1379 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
| 1380 | 1380 | |
| 1381 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
| 1382 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
| 1383 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
| 1381 | +function wpinv_settings_sanitize_input($value, $key) { |
|
| 1382 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
| 1383 | + $value = wpinv_sanitize_amount($value, 4); |
|
| 1384 | 1384 | $value = $value >= 100 ? 99 : $value; |
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | return $value; |
| 1388 | 1388 | } |
| 1389 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
| 1390 | 1389 | \ No newline at end of file |
| 1390 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
| 1391 | 1391 | \ No newline at end of file |
@@ -152,57 +152,57 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function wpinv_admin_messages() { |
| 155 | - global $wpinv_options; |
|
| 155 | + global $wpinv_options; |
|
| 156 | 156 | |
| 157 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 158 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 159 | - } |
|
| 157 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 158 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 162 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 163 | - } |
|
| 161 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 162 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 166 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 167 | - } |
|
| 165 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 166 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 170 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 171 | - } |
|
| 169 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 170 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 174 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 175 | - } |
|
| 173 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 174 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 178 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 179 | - } |
|
| 177 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 178 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 182 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 181 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 182 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
| 186 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 186 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
| 190 | 190 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 194 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 195 | - } |
|
| 193 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 194 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 198 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 199 | - } |
|
| 197 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 198 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 202 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 203 | - } |
|
| 201 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 202 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - settings_errors( 'wpinv-notices' ); |
|
| 205 | + settings_errors( 'wpinv-notices' ); |
|
| 206 | 206 | } |
| 207 | 207 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
| 208 | 208 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | break; |
| 344 | 344 | case 'id' : |
| 345 | 345 | echo $post->ID; |
| 346 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 346 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 347 | 347 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
| 348 | 348 | if ( $wpinv_euvat->allow_vat_rules() ) { |
| 349 | 349 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,228 +7,228 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_columns( $columns ) { |
|
| 14 | +function wpinv_columns($columns) { |
|
| 15 | 15 | $columns = array( |
| 16 | 16 | 'cb' => $columns['cb'], |
| 17 | - 'ID' => __( 'ID', 'invoicing' ), |
|
| 18 | - 'details' => __( 'Details', 'invoicing' ), |
|
| 17 | + 'ID' => __('ID', 'invoicing'), |
|
| 18 | + 'details' => __('Details', 'invoicing'), |
|
| 19 | 19 | //'email' => __( 'Email', 'invoicing' ), |
| 20 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 21 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 22 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
| 23 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
| 20 | + 'customer' => __('Customer', 'invoicing'), |
|
| 21 | + 'amount' => __('Amount', 'invoicing'), |
|
| 22 | + 'invoice_date' => __('Date', 'invoicing'), |
|
| 23 | + 'status' => __('Status', 'invoicing'), |
|
| 24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 28 | 28 | } |
| 29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
| 29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
| 30 | 30 | |
| 31 | -function wpinv_bulk_actions( $actions ) { |
|
| 32 | - if ( isset( $actions['edit'] ) ) { |
|
| 33 | - unset( $actions['edit'] ); |
|
| 31 | +function wpinv_bulk_actions($actions) { |
|
| 32 | + if (isset($actions['edit'])) { |
|
| 33 | + unset($actions['edit']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $actions; |
| 37 | 37 | } |
| 38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 39 | 39 | |
| 40 | -function wpinv_sortable_columns( $columns ) { |
|
| 40 | +function wpinv_sortable_columns($columns) { |
|
| 41 | 41 | $columns = array( |
| 42 | - 'ID' => array( 'ID', true ), |
|
| 43 | - 'amount' => array( 'amount', false ), |
|
| 44 | - 'invoice_date' => array( 'date', false ), |
|
| 45 | - 'customer' => array( 'customer', false ), |
|
| 42 | + 'ID' => array('ID', true), |
|
| 43 | + 'amount' => array('amount', false), |
|
| 44 | + 'invoice_date' => array('date', false), |
|
| 45 | + 'customer' => array('customer', false), |
|
| 46 | 46 | ///'email' => array( 'email', false ), |
| 47 | - 'status' => array( 'status', false ), |
|
| 47 | + 'status' => array('status', false), |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
| 50 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
| 51 | 51 | } |
| 52 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
| 52 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
| 53 | 53 | |
| 54 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 55 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
| 54 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 55 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
| 56 | 56 | global $post, $wpi_invoice; |
| 57 | 57 | |
| 58 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
| 59 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
| 58 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
| 59 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $value = NULL; |
| 63 | 63 | |
| 64 | - switch ( $column_name ) { |
|
| 64 | + switch ($column_name) { |
|
| 65 | 65 | case 'email' : |
| 66 | - $value = $wpi_invoice->get_email(); |
|
| 66 | + $value = $wpi_invoice->get_email(); |
|
| 67 | 67 | break; |
| 68 | 68 | case 'customer' : |
| 69 | 69 | $customer_name = $wpi_invoice->get_user_full_name(); |
| 70 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
| 71 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
| 72 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 70 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
| 71 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
| 72 | + if ($email = $wpi_invoice->get_email()) { |
|
| 73 | 73 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
| 74 | 74 | } |
| 75 | 75 | break; |
| 76 | 76 | case 'amount' : |
| 77 | - echo $wpi_invoice->get_total( true ); |
|
| 77 | + echo $wpi_invoice->get_total(true); |
|
| 78 | 78 | break; |
| 79 | 79 | case 'invoice_date' : |
| 80 | - $date_format = get_option( 'date_format' ); |
|
| 81 | - $time_format = get_option( 'time_format' ); |
|
| 82 | - $date_time_format = $date_format . ' '. $time_format; |
|
| 80 | + $date_format = get_option('date_format'); |
|
| 81 | + $time_format = get_option('time_format'); |
|
| 82 | + $date_time_format = $date_format . ' ' . $time_format; |
|
| 83 | 83 | |
| 84 | - $t_time = get_the_time( $date_time_format ); |
|
| 84 | + $t_time = get_the_time($date_time_format); |
|
| 85 | 85 | $m_time = $post->post_date; |
| 86 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 86 | + $h_time = mysql2date($date_format, $m_time); |
|
| 87 | 87 | |
| 88 | 88 | $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
| 89 | 89 | break; |
| 90 | 90 | case 'status' : |
| 91 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
| 91 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
| 92 | 92 | break; |
| 93 | 93 | case 'details' : |
| 94 | - $edit_link = get_edit_post_link( $post->ID ); |
|
| 95 | - $value = '<a href="' . esc_url( $edit_link ) . '">' . __( 'View Invoice Details', 'invoicing' ) . '</a>'; |
|
| 94 | + $edit_link = get_edit_post_link($post->ID); |
|
| 95 | + $value = '<a href="' . esc_url($edit_link) . '">' . __('View Invoice Details', 'invoicing') . '</a>'; |
|
| 96 | 96 | break; |
| 97 | 97 | case 'wpi_actions' : |
| 98 | 98 | $value = ''; |
| 99 | - if ( !empty( $post->post_name ) ) { |
|
| 100 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 99 | + if (!empty($post->post_name)) { |
|
| 100 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 104 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 103 | + if ($email = $wpi_invoice->get_email()) { |
|
| 104 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | break; |
| 108 | 108 | default: |
| 109 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
| 109 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
| 110 | 110 | break; |
| 111 | 111 | |
| 112 | 112 | } |
| 113 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
| 113 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
| 114 | 114 | |
| 115 | - if ( $value !== NULL ) { |
|
| 115 | + if ($value !== NULL) { |
|
| 116 | 116 | echo $value; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 120 | +function wpinv_admin_post_id($id = 0) { |
|
| 121 | 121 | global $post; |
| 122 | 122 | |
| 123 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 123 | + if (isset($id) && !empty($id)) { |
|
| 124 | 124 | return (int)$id; |
| 125 | - } else if ( get_the_ID() ) { |
|
| 126 | - return (int) get_the_ID(); |
|
| 127 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
| 128 | - return (int) $post->ID; |
|
| 129 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
| 130 | - return (int) $_GET['post']; |
|
| 131 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
| 132 | - return (int) $_GET['id']; |
|
| 133 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
| 134 | - return (int) $_POST['id']; |
|
| 125 | + } else if (get_the_ID()) { |
|
| 126 | + return (int)get_the_ID(); |
|
| 127 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
| 128 | + return (int)$post->ID; |
|
| 129 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 130 | + return (int)$_GET['post']; |
|
| 131 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 132 | + return (int)$_GET['id']; |
|
| 133 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 134 | + return (int)$_POST['id']; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | return null; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 141 | - if ( !$id ) { |
|
| 140 | +function wpinv_admin_post_type($id = 0) { |
|
| 141 | + if (!$id) { |
|
| 142 | 142 | $id = wpinv_admin_post_id(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $type = get_post_type( $id ); |
|
| 145 | + $type = get_post_type($id); |
|
| 146 | 146 | |
| 147 | - if ( !$type ) { |
|
| 148 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
| 147 | + if (!$type) { |
|
| 148 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 151 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function wpinv_admin_messages() { |
| 155 | 155 | global $wpinv_options; |
| 156 | 156 | |
| 157 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 158 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 157 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 158 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 162 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 161 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 162 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 166 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 165 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 166 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 170 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 169 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 170 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 174 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 173 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 174 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 178 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 177 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 178 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 182 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 181 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 182 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 186 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 185 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 186 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 190 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
| 189 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 190 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 194 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 193 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 194 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 198 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 197 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 198 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 202 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 201 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 202 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - settings_errors( 'wpinv-notices' ); |
|
| 205 | + settings_errors('wpinv-notices'); |
|
| 206 | 206 | } |
| 207 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 207 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 208 | 208 | |
| 209 | -function wpinv_items_columns( $existing_columns ) { |
|
| 209 | +function wpinv_items_columns($existing_columns) { |
|
| 210 | 210 | global $wpinv_euvat; |
| 211 | 211 | |
| 212 | 212 | $columns = array(); |
| 213 | 213 | $columns['cb'] = $existing_columns['cb']; |
| 214 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
| 215 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
| 216 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 217 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
| 214 | + $columns['title'] = __('Title', 'invoicing'); |
|
| 215 | + $columns['price'] = __('Price', 'invoicing'); |
|
| 216 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 217 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
| 218 | 218 | } |
| 219 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 220 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
| 219 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 220 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
| 221 | 221 | } |
| 222 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
| 223 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
| 224 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
| 225 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
| 222 | + $columns['type'] = __('Type', 'invoicing'); |
|
| 223 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
| 224 | + $columns['date'] = __('Date', 'invoicing'); |
|
| 225 | + $columns['id'] = __('ID', 'invoicing'); |
|
| 226 | 226 | |
| 227 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
| 227 | + return apply_filters('wpinv_items_columns', $columns); |
|
| 228 | 228 | } |
| 229 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
| 229 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
| 230 | 230 | |
| 231 | -function wpinv_items_sortable_columns( $columns ) { |
|
| 231 | +function wpinv_items_sortable_columns($columns) { |
|
| 232 | 232 | $columns['price'] = 'price'; |
| 233 | 233 | $columns['vat_rule'] = 'vat_rule'; |
| 234 | 234 | $columns['vat_class'] = 'vat_class'; |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | return $columns; |
| 240 | 240 | } |
| 241 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
| 241 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
| 242 | 242 | |
| 243 | -function wpinv_item_quick_edit( $column_name, $post_type ) { |
|
| 244 | - if ( !( $post_type == 'wpi_item' && $column_name == 'price' ) ) { |
|
| 243 | +function wpinv_item_quick_edit($column_name, $post_type) { |
|
| 244 | + if (!($post_type == 'wpi_item' && $column_name == 'price')) { |
|
| 245 | 245 | return; |
| 246 | 246 | } |
| 247 | 247 | global $wpinv_euvat, $post; |
@@ -249,23 +249,23 @@ discard block |
||
| 249 | 249 | $symbol = wpinv_currency_symbol(); |
| 250 | 250 | $position = wpinv_currency_position(); |
| 251 | 251 | |
| 252 | - $price = wpinv_get_item_price( $post->ID ); |
|
| 253 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
| 252 | + $price = wpinv_get_item_price($post->ID); |
|
| 253 | + $item_type = wpinv_get_item_type($post->ID); |
|
| 254 | 254 | ?> |
| 255 | 255 | <fieldset class="inline-edit-col-right wpi-inline-item-col"> |
| 256 | 256 | <div class="inline-edit-col"> |
| 257 | 257 | <div class="inline-edit-group wp-clearfix"> |
| 258 | 258 | <label class="inline-edit-wpinv-price"> |
| 259 | - <span class="title"><?php _e( 'Item price', 'invoicing' );?></span> |
|
| 260 | - <span class="input-text-wrap"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID;?>"><?php echo ( $position == 'right' ? $symbol . ' ' : '' );?></span> |
|
| 259 | + <span class="title"><?php _e('Item price', 'invoicing'); ?></span> |
|
| 260 | + <span class="input-text-wrap"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID; ?>"><?php echo ($position == 'right' ? $symbol . ' ' : ''); ?></span> |
|
| 261 | 261 | </label> |
| 262 | 262 | </div> |
| 263 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); ?> |
|
| 263 | + <?php if ($wpinv_euvat->allow_vat_rules()) { $rule_type = $wpinv_euvat->get_item_rule($post->ID); ?> |
|
| 264 | 264 | <div class="inline-edit-group wp-clearfix"> |
| 265 | 265 | <label class="inline-edit-wpinv-vat-rate"> |
| 266 | - <span class="title"><?php _e( 'VAT rule type to use', 'invoicing' );?></span> |
|
| 266 | + <span class="title"><?php _e('VAT rule type to use', 'invoicing'); ?></span> |
|
| 267 | 267 | <span class="input-text-wrap"> |
| 268 | - <?php echo wpinv_html_select( array( |
|
| 268 | + <?php echo wpinv_html_select(array( |
|
| 269 | 269 | 'options' => $wpinv_euvat->get_rules(), |
| 270 | 270 | 'name' => '_wpinv_vat_rules', |
| 271 | 271 | 'id' => 'wpinv_vat_rules-' . $post->ID, |
@@ -273,16 +273,16 @@ discard block |
||
| 273 | 273 | 'show_option_all' => false, |
| 274 | 274 | 'show_option_none' => false, |
| 275 | 275 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
| 276 | - ) ); ?> |
|
| 276 | + )); ?> |
|
| 277 | 277 | </span> |
| 278 | 278 | </label> |
| 279 | 279 | </div> |
| 280 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { $vat_class = $wpinv_euvat->get_item_class( $post->ID ); ?> |
|
| 280 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { $vat_class = $wpinv_euvat->get_item_class($post->ID); ?> |
|
| 281 | 281 | <div class="inline-edit-group wp-clearfix"> |
| 282 | 282 | <label class="inline-edit-wpinv-vat-class"> |
| 283 | - <span class="title"><?php _e( 'VAT class to use', 'invoicing' );?></span> |
|
| 283 | + <span class="title"><?php _e('VAT class to use', 'invoicing'); ?></span> |
|
| 284 | 284 | <span class="input-text-wrap"> |
| 285 | - <?php echo wpinv_html_select( array( |
|
| 285 | + <?php echo wpinv_html_select(array( |
|
| 286 | 286 | 'options' => $wpinv_euvat->get_all_classes(), |
| 287 | 287 | 'name' => '_wpinv_vat_class', |
| 288 | 288 | 'id' => 'wpinv_vat_class-' . $post->ID, |
@@ -290,16 +290,16 @@ discard block |
||
| 290 | 290 | 'show_option_all' => false, |
| 291 | 291 | 'show_option_none' => false, |
| 292 | 292 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
| 293 | - ) ); ?> |
|
| 293 | + )); ?> |
|
| 294 | 294 | </span> |
| 295 | 295 | </label> |
| 296 | 296 | </div> |
| 297 | 297 | <?php } ?> |
| 298 | 298 | <div class="inline-edit-group wp-clearfix"> |
| 299 | 299 | <label class="inline-edit-wpinv-type"> |
| 300 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
| 300 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
| 301 | 301 | <span class="input-text-wrap"> |
| 302 | - <?php echo wpinv_html_select( array( |
|
| 302 | + <?php echo wpinv_html_select(array( |
|
| 303 | 303 | 'options' => wpinv_get_item_types(), |
| 304 | 304 | 'name' => '_wpinv_item_type', |
| 305 | 305 | 'id' => 'wpinv_item_type-' . $post->ID, |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | 'show_option_all' => false, |
| 308 | 308 | 'show_option_none' => false, |
| 309 | 309 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
| 310 | - ) ); ?> |
|
| 310 | + )); ?> |
|
| 311 | 311 | </span> |
| 312 | 312 | </label> |
| 313 | 313 | </div> |
@@ -315,150 +315,150 @@ discard block |
||
| 315 | 315 | </fieldset> |
| 316 | 316 | <?php |
| 317 | 317 | } |
| 318 | -add_action( 'quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 ); |
|
| 319 | -add_action( 'bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 ); |
|
| 318 | +add_action('quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2); |
|
| 319 | +add_action('bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2); |
|
| 320 | 320 | |
| 321 | -function wpinv_items_table_custom_column( $column ) { |
|
| 321 | +function wpinv_items_table_custom_column($column) { |
|
| 322 | 322 | global $wpinv_euvat, $post, $wpi_item; |
| 323 | 323 | |
| 324 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
| 325 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
| 324 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
| 325 | + $wpi_item = new WPInv_Item($post->ID); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - switch ( $column ) { |
|
| 328 | + switch ($column) { |
|
| 329 | 329 | case 'price' : |
| 330 | - echo wpinv_item_price( $post->ID ); |
|
| 330 | + echo wpinv_item_price($post->ID); |
|
| 331 | 331 | break; |
| 332 | 332 | case 'vat_rule' : |
| 333 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
| 333 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
| 334 | 334 | break; |
| 335 | 335 | case 'vat_class' : |
| 336 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
| 336 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
| 337 | 337 | break; |
| 338 | 338 | case 'type' : |
| 339 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 339 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 340 | 340 | break; |
| 341 | 341 | case 'recurring' : |
| 342 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
| 342 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
| 343 | 343 | break; |
| 344 | 344 | case 'id' : |
| 345 | 345 | echo $post->ID; |
| 346 | 346 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
| 347 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
| 348 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 349 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
| 347 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
| 348 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 349 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
| 350 | 350 | } |
| 351 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 352 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
| 351 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 352 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
| 353 | 353 | } |
| 354 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
| 354 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
| 355 | 355 | </div>'; |
| 356 | 356 | break; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
| 359 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
| 360 | 360 | } |
| 361 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
| 361 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
| 362 | 362 | |
| 363 | 363 | function wpinv_add_items_filters() { |
| 364 | 364 | global $wpinv_euvat, $typenow; |
| 365 | 365 | |
| 366 | 366 | // Checks if the current post type is 'item' |
| 367 | - if ( $typenow == 'wpi_item') { |
|
| 368 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 369 | - echo wpinv_html_select( array( |
|
| 370 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
| 367 | + if ($typenow == 'wpi_item') { |
|
| 368 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 369 | + echo wpinv_html_select(array( |
|
| 370 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
| 371 | 371 | 'name' => 'vat_rule', |
| 372 | 372 | 'id' => 'vat_rule', |
| 373 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
| 373 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
| 374 | 374 | 'show_option_all' => false, |
| 375 | 375 | 'show_option_none' => false, |
| 376 | 376 | 'class' => 'gdmbx2-text-medium', |
| 377 | - ) ); |
|
| 377 | + )); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 381 | - echo wpinv_html_select( array( |
|
| 382 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
| 380 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 381 | + echo wpinv_html_select(array( |
|
| 382 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
| 383 | 383 | 'name' => 'vat_class', |
| 384 | 384 | 'id' => 'vat_class', |
| 385 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
| 385 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
| 386 | 386 | 'show_option_all' => false, |
| 387 | 387 | 'show_option_none' => false, |
| 388 | 388 | 'class' => 'gdmbx2-text-medium', |
| 389 | - ) ); |
|
| 389 | + )); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - echo wpinv_html_select( array( |
|
| 393 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
| 392 | + echo wpinv_html_select(array( |
|
| 393 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
| 394 | 394 | 'name' => 'type', |
| 395 | 395 | 'id' => 'type', |
| 396 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
| 396 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
| 397 | 397 | 'show_option_all' => false, |
| 398 | 398 | 'show_option_none' => false, |
| 399 | 399 | 'class' => 'gdmbx2-text-medium', |
| 400 | - ) ); |
|
| 400 | + )); |
|
| 401 | 401 | |
| 402 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
| 402 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
| 403 | 403 | echo '<input type="hidden" name="all_posts" value="1" />'; |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
| 407 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
| 408 | 408 | |
| 409 | -function wpinv_send_invoice_after_save( $post_id ) { |
|
| 409 | +function wpinv_send_invoice_after_save($post_id) { |
|
| 410 | 410 | // If this is just a revision, don't send the email. |
| 411 | - if ( wp_is_post_revision( $post_id ) ) { |
|
| 411 | + if (wp_is_post_revision($post_id)) { |
|
| 412 | 412 | return; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if ( !current_user_can( 'manage_options' ) || !(get_post_type( $post_id ) == 'wpi_invoice' || get_post_type( $post_id ) == 'wpi_quote') ) { |
|
| 415 | + if (!current_user_can('manage_options') || !(get_post_type($post_id) == 'wpi_invoice' || get_post_type($post_id) == 'wpi_quote')) { |
|
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( !empty( $_POST['wpi_save_send'] ) ) { |
|
| 420 | - wpinv_user_invoice_notification( $post_id ); |
|
| 419 | + if (!empty($_POST['wpi_save_send'])) { |
|
| 420 | + wpinv_user_invoice_notification($post_id); |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | -add_action( 'save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
| 423 | +add_action('save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1); |
|
| 424 | 424 | |
| 425 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
| 426 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && $data['post_type'] == 'wpi_invoice' ) { |
|
| 427 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
| 428 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
| 425 | +function wpinv_send_register_new_user($data, $postarr) { |
|
| 426 | + if (current_user_can('manage_options') && !empty($data['post_type']) && $data['post_type'] == 'wpi_invoice') { |
|
| 427 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
| 428 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
| 429 | 429 | |
| 430 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
| 431 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
| 432 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
| 433 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
| 434 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
| 435 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
| 430 | + if ($is_new_user && $email && !email_exists($email)) { |
|
| 431 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
| 432 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
| 433 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
| 434 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
| 435 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
| 436 | 436 | |
| 437 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
| 438 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 439 | - $user_login = sanitize_user( str_replace( ' ', '', $user_company ), true ); |
|
| 437 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
| 438 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 439 | + $user_login = sanitize_user(str_replace(' ', '', $user_company), true); |
|
| 440 | 440 | |
| 441 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 441 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 442 | 442 | $user_login = $email; |
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | $userdata = array( |
| 447 | 447 | 'user_login' => $user_login, |
| 448 | - 'user_pass' => wp_generate_password( 12, false ), |
|
| 449 | - 'user_email' => sanitize_text_field( $email ), |
|
| 448 | + 'user_pass' => wp_generate_password(12, false), |
|
| 449 | + 'user_email' => sanitize_text_field($email), |
|
| 450 | 450 | 'first_name' => $first_name, |
| 451 | 451 | 'last_name' => $last_name, |
| 452 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
| 452 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
| 453 | 453 | 'nickname' => $display_name, |
| 454 | 454 | 'display_name' => $display_name, |
| 455 | 455 | ); |
| 456 | 456 | |
| 457 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
| 457 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
| 458 | 458 | |
| 459 | - $new_user_id = wp_insert_user( $userdata ); |
|
| 459 | + $new_user_id = wp_insert_user($userdata); |
|
| 460 | 460 | |
| 461 | - if ( !is_wp_error( $new_user_id ) ) { |
|
| 461 | + if (!is_wp_error($new_user_id)) { |
|
| 462 | 462 | $data['post_author'] = $new_user_id; |
| 463 | 463 | $_POST['post_author'] = $new_user_id; |
| 464 | 464 | $_POST['post_author_override'] = $new_user_id; |
@@ -479,27 +479,27 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | $meta = array(); |
| 481 | 481 | ///$meta['_wpinv_user_id'] = $new_user_id; |
| 482 | - foreach ( $meta_fields as $field ) { |
|
| 483 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
| 482 | + foreach ($meta_fields as $field) { |
|
| 483 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
| 486 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
| 487 | 487 | |
| 488 | 488 | // Update user meta. |
| 489 | - foreach ( $meta as $key => $value ) { |
|
| 490 | - update_user_meta( $new_user_id, $key, $value ); |
|
| 489 | + foreach ($meta as $key => $value) { |
|
| 490 | + update_user_meta($new_user_id, $key, $value); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
| 493 | + if (function_exists('wp_send_new_user_notifications')) { |
|
| 494 | 494 | // Send email notifications related to the creation of new user. |
| 495 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
| 495 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
| 496 | 496 | } |
| 497 | 497 | } else { |
| 498 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
| 498 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | return $data; |
| 504 | 504 | } |
| 505 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
| 506 | 505 | \ No newline at end of file |
| 506 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
| 507 | 507 | \ No newline at end of file |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | ) ); |
| 14 | 14 | echo '<div class="' . implode( ' ', $classes ) . '">'; |
| 15 | 15 | // Loop error codes and display errors |
| 16 | - foreach ( $errors as $error_id => $error ) { |
|
| 16 | + foreach ( $errors as $error_id => $error ) { |
|
| 17 | 17 | echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>'; |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | echo '</div>'; |
| 20 | 20 | wpinv_clear_errors(); |
| 21 | 21 | } |
@@ -1,61 +1,61 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function wpinv_print_errors() { |
| 8 | 8 | $errors = wpinv_get_errors(); |
| 9 | 9 | |
| 10 | - if ( $errors ) { |
|
| 11 | - $classes = apply_filters( 'wpinv_error_class', array( |
|
| 10 | + if ($errors) { |
|
| 11 | + $classes = apply_filters('wpinv_error_class', array( |
|
| 12 | 12 | 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-error' |
| 13 | - ) ); |
|
| 14 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 13 | + )); |
|
| 14 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 15 | 15 | // Loop error codes and display errors |
| 16 | - foreach ( $errors as $error_id => $error ) { |
|
| 17 | - echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>'; |
|
| 16 | + foreach ($errors as $error_id => $error) { |
|
| 17 | + echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __('Error', 'invoicing') . '</strong>: ' . $error . '</p>'; |
|
| 18 | 18 | } |
| 19 | 19 | echo '</div>'; |
| 20 | 20 | wpinv_clear_errors(); |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | -add_action( 'wpinv_purchase_form_before_submit', 'wpinv_print_errors' ); |
|
| 24 | -add_action( 'wpinv_ajax_checkout_errors', 'wpinv_print_errors' ); |
|
| 23 | +add_action('wpinv_purchase_form_before_submit', 'wpinv_print_errors'); |
|
| 24 | +add_action('wpinv_ajax_checkout_errors', 'wpinv_print_errors'); |
|
| 25 | 25 | |
| 26 | 26 | function wpinv_get_errors() { |
| 27 | 27 | global $wpi_session; |
| 28 | 28 | |
| 29 | - return $wpi_session->get( 'wpinv_errors' ); |
|
| 29 | + return $wpi_session->get('wpinv_errors'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -function wpinv_set_error( $error_id, $error_message ) { |
|
| 32 | +function wpinv_set_error($error_id, $error_message) { |
|
| 33 | 33 | global $wpi_session; |
| 34 | 34 | |
| 35 | 35 | $errors = wpinv_get_errors(); |
| 36 | 36 | |
| 37 | - if ( ! $errors ) { |
|
| 37 | + if (!$errors) { |
|
| 38 | 38 | $errors = array(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $errors[ $error_id ] = $error_message; |
|
| 42 | - $wpi_session->set( 'wpinv_errors', $errors ); |
|
| 41 | + $errors[$error_id] = $error_message; |
|
| 42 | + $wpi_session->set('wpinv_errors', $errors); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_clear_errors() { |
| 46 | 46 | global $wpi_session; |
| 47 | 47 | |
| 48 | - $wpi_session->set( 'wpinv_errors', null ); |
|
| 48 | + $wpi_session->set('wpinv_errors', null); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -function wpinv_unset_error( $error_id ) { |
|
| 51 | +function wpinv_unset_error($error_id) { |
|
| 52 | 52 | global $wpi_session; |
| 53 | 53 | |
| 54 | 54 | $errors = wpinv_get_errors(); |
| 55 | 55 | |
| 56 | - if ( $errors ) { |
|
| 57 | - unset( $errors[ $error_id ] ); |
|
| 58 | - $wpi_session->set( 'wpinv_errors', $errors ); |
|
| 56 | + if ($errors) { |
|
| 57 | + unset($errors[$error_id]); |
|
| 58 | + $wpi_session->set('wpinv_errors', $errors); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | die(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
| 67 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 68 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 69 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 66 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
| 67 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
| 68 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
| 69 | + wp_die($message, $title, array('response' => $status)); |
|
| 70 | 70 | } |