@@ -8,291 +8,291 @@ |
||
| 8 | 8 | * @since 1.0.0 |
| 9 | 9 | */ |
| 10 | 10 | class WPInv_Session { |
| 11 | - /** |
|
| 12 | - * Holds our session data. |
|
| 13 | - * |
|
| 14 | - * @var array |
|
| 15 | - * @access private |
|
| 16 | - * @since 1.0.0 |
|
| 17 | - */ |
|
| 18 | - private $session; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Whether to use PHP $_SESSION or WP_Session. |
|
| 22 | - * |
|
| 23 | - * @var bool |
|
| 24 | - * @access private |
|
| 25 | - * @since 1.0.0 |
|
| 26 | - */ |
|
| 27 | - private $use_php_sessions = false; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Session index prefix. |
|
| 31 | - * |
|
| 32 | - * @var string |
|
| 33 | - * @access private |
|
| 34 | - * @since 1.0.0 |
|
| 35 | - */ |
|
| 36 | - private $prefix = ''; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Get things started. |
|
| 40 | - * |
|
| 41 | - * Defines our WP_Session constants, includes the necessary libraries and |
|
| 42 | - * retrieves the WP Session instance. |
|
| 43 | - * |
|
| 44 | - * @since 1.0.0 |
|
| 45 | - */ |
|
| 46 | - public function __construct() { |
|
| 47 | - $this->use_php_sessions = $this->use_php_sessions(); |
|
| 48 | - |
|
| 49 | - if ( $this->use_php_sessions ) { |
|
| 50 | - if ( is_multisite() ) { |
|
| 51 | - $this->prefix = '_' . get_current_blog_id(); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant) |
|
| 55 | - add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); |
|
| 56 | - } else { |
|
| 57 | - // Use WP_Session (default) |
|
| 58 | - if ( !defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 59 | - define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' ); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ( !class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 63 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php'; |
|
| 64 | - } |
|
| 11 | + /** |
|
| 12 | + * Holds our session data. |
|
| 13 | + * |
|
| 14 | + * @var array |
|
| 15 | + * @access private |
|
| 16 | + * @since 1.0.0 |
|
| 17 | + */ |
|
| 18 | + private $session; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Whether to use PHP $_SESSION or WP_Session. |
|
| 22 | + * |
|
| 23 | + * @var bool |
|
| 24 | + * @access private |
|
| 25 | + * @since 1.0.0 |
|
| 26 | + */ |
|
| 27 | + private $use_php_sessions = false; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Session index prefix. |
|
| 31 | + * |
|
| 32 | + * @var string |
|
| 33 | + * @access private |
|
| 34 | + * @since 1.0.0 |
|
| 35 | + */ |
|
| 36 | + private $prefix = ''; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Get things started. |
|
| 40 | + * |
|
| 41 | + * Defines our WP_Session constants, includes the necessary libraries and |
|
| 42 | + * retrieves the WP Session instance. |
|
| 43 | + * |
|
| 44 | + * @since 1.0.0 |
|
| 45 | + */ |
|
| 46 | + public function __construct() { |
|
| 47 | + $this->use_php_sessions = $this->use_php_sessions(); |
|
| 48 | + |
|
| 49 | + if ( $this->use_php_sessions ) { |
|
| 50 | + if ( is_multisite() ) { |
|
| 51 | + $this->prefix = '_' . get_current_blog_id(); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant) |
|
| 55 | + add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); |
|
| 56 | + } else { |
|
| 57 | + // Use WP_Session (default) |
|
| 58 | + if ( !defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 59 | + define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' ); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ( !class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 63 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php'; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - if ( !class_exists( 'WP_Session_Utils' ) ) { |
|
| 67 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php'; |
|
| 68 | - } |
|
| 66 | + if ( !class_exists( 'WP_Session_Utils' ) ) { |
|
| 67 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php'; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) { |
|
| 71 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php'; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if ( !class_exists( 'WP_Session' ) ) { |
|
| 75 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php'; |
|
| 76 | - require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php'; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 80 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 84 | - add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); |
|
| 85 | - } else { |
|
| 86 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Setup the WP_Session instance. |
|
| 92 | - * |
|
| 93 | - * @access public |
|
| 94 | - * @since 1.0.0 |
|
| 95 | - * @return void |
|
| 96 | - */ |
|
| 97 | - public function init() { |
|
| 98 | - if ( $this->use_php_sessions ) { |
|
| 99 | - $this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array(); |
|
| 100 | - } else { |
|
| 101 | - $this->session = WP_Session::get_instance(); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - return $this->session; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Retrieve session ID. |
|
| 109 | - * |
|
| 110 | - * @access public |
|
| 111 | - * @since 1.0.0 |
|
| 112 | - * @return string Session ID |
|
| 113 | - */ |
|
| 114 | - public function get_id() { |
|
| 115 | - if ( $this->use_php_sessions ) { |
|
| 116 | - $session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL; |
|
| 117 | - } else { |
|
| 118 | - $session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL; |
|
| 119 | - } |
|
| 120 | - return $session_id; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Retrieve a session variable. |
|
| 125 | - * |
|
| 126 | - * @access public |
|
| 127 | - * @since 1.0.0 |
|
| 128 | - * @param string $key Session key |
|
| 129 | - * @return string Session variable |
|
| 130 | - */ |
|
| 131 | - public function get( $key ) { |
|
| 132 | - $key = sanitize_key( $key ); |
|
| 133 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Set a session variable |
|
| 138 | - * |
|
| 139 | - * @since 1.0.0 |
|
| 140 | - * |
|
| 141 | - * @param string $key Session key |
|
| 142 | - * @param integer $value Session variable |
|
| 143 | - * @return string Session variable |
|
| 144 | - */ |
|
| 145 | - public function set( $key, $value ) { |
|
| 146 | - $key = sanitize_key( $key ); |
|
| 147 | - |
|
| 148 | - if ( is_array( $value ) ) { |
|
| 149 | - $this->session[ $key ] = maybe_serialize( $value ); |
|
| 150 | - } else { |
|
| 151 | - $this->session[ $key ] = $value; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - if ( $this->use_php_sessions ) { |
|
| 155 | - $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - return $this->session[ $key ]; |
|
| 159 | - } |
|
| 70 | + if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) { |
|
| 71 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php'; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if ( !class_exists( 'WP_Session' ) ) { |
|
| 75 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php'; |
|
| 76 | + require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php'; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 80 | + add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 84 | + add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); |
|
| 85 | + } else { |
|
| 86 | + add_action( 'init', array( $this, 'init' ), -1 ); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Setup the WP_Session instance. |
|
| 92 | + * |
|
| 93 | + * @access public |
|
| 94 | + * @since 1.0.0 |
|
| 95 | + * @return void |
|
| 96 | + */ |
|
| 97 | + public function init() { |
|
| 98 | + if ( $this->use_php_sessions ) { |
|
| 99 | + $this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array(); |
|
| 100 | + } else { |
|
| 101 | + $this->session = WP_Session::get_instance(); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + return $this->session; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Retrieve session ID. |
|
| 109 | + * |
|
| 110 | + * @access public |
|
| 111 | + * @since 1.0.0 |
|
| 112 | + * @return string Session ID |
|
| 113 | + */ |
|
| 114 | + public function get_id() { |
|
| 115 | + if ( $this->use_php_sessions ) { |
|
| 116 | + $session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL; |
|
| 117 | + } else { |
|
| 118 | + $session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL; |
|
| 119 | + } |
|
| 120 | + return $session_id; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Retrieve a session variable. |
|
| 125 | + * |
|
| 126 | + * @access public |
|
| 127 | + * @since 1.0.0 |
|
| 128 | + * @param string $key Session key |
|
| 129 | + * @return string Session variable |
|
| 130 | + */ |
|
| 131 | + public function get( $key ) { |
|
| 132 | + $key = sanitize_key( $key ); |
|
| 133 | + return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Set a session variable |
|
| 138 | + * |
|
| 139 | + * @since 1.0.0 |
|
| 140 | + * |
|
| 141 | + * @param string $key Session key |
|
| 142 | + * @param integer $value Session variable |
|
| 143 | + * @return string Session variable |
|
| 144 | + */ |
|
| 145 | + public function set( $key, $value ) { |
|
| 146 | + $key = sanitize_key( $key ); |
|
| 147 | + |
|
| 148 | + if ( is_array( $value ) ) { |
|
| 149 | + $this->session[ $key ] = maybe_serialize( $value ); |
|
| 150 | + } else { |
|
| 151 | + $this->session[ $key ] = $value; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + if ( $this->use_php_sessions ) { |
|
| 155 | + $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + return $this->session[ $key ]; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Unset a session variable. |
|
| 163 | - * |
|
| 164 | - * @since 1.0.0 |
|
| 165 | - * |
|
| 166 | - * @param string|array $key Session key. |
|
| 167 | - * @param integer $value Session variable. |
|
| 168 | - * @return string Session variable. |
|
| 169 | - */ |
|
| 170 | - public function un_set( $key ) { |
|
| 171 | - if ( empty( $key ) ) { |
|
| 172 | - return false; |
|
| 173 | - } |
|
| 161 | + /** |
|
| 162 | + * Unset a session variable. |
|
| 163 | + * |
|
| 164 | + * @since 1.0.0 |
|
| 165 | + * |
|
| 166 | + * @param string|array $key Session key. |
|
| 167 | + * @param integer $value Session variable. |
|
| 168 | + * @return string Session variable. |
|
| 169 | + */ |
|
| 170 | + public function un_set( $key ) { |
|
| 171 | + if ( empty( $key ) ) { |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - if ( is_array( $key ) ) { |
|
| 176 | - foreach ($key as $index) { |
|
| 177 | - $index = sanitize_key( $index ); |
|
| 175 | + if ( is_array( $key ) ) { |
|
| 176 | + foreach ($key as $index) { |
|
| 177 | + $index = sanitize_key( $index ); |
|
| 178 | 178 | |
| 179 | - if ( $index && isset( $this->session[ $index ] ) ) { |
|
| 180 | - unset( $this->session[ $index ] ); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } else { |
|
| 184 | - $key = sanitize_key( $key ); |
|
| 179 | + if ( $index && isset( $this->session[ $index ] ) ) { |
|
| 180 | + unset( $this->session[ $index ] ); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } else { |
|
| 184 | + $key = sanitize_key( $key ); |
|
| 185 | 185 | |
| 186 | - if ( isset( $this->session[ $key ] ) ) { |
|
| 187 | - unset( $this->session[ $key ] ); |
|
| 188 | - } |
|
| 189 | - } |
|
| 186 | + if ( isset( $this->session[ $key ] ) ) { |
|
| 187 | + unset( $this->session[ $key ] ); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - if ( $this->use_php_sessions ) { |
|
| 192 | - $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
| 193 | - } |
|
| 191 | + if ( $this->use_php_sessions ) { |
|
| 192 | + $_SESSION['wpi' . $this->prefix ] = $this->session; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - return true; |
|
| 196 | - } |
|
| 195 | + return true; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Check a session variable is set or not. |
|
| 200 | - * |
|
| 201 | - * @since 1.0.0 |
|
| 202 | - * |
|
| 203 | - * @param string $key Session key. |
|
| 204 | - * @param integer $value Session variable. |
|
| 205 | - * @return string Session variable. |
|
| 206 | - */ |
|
| 207 | - public function is_set( $key ) { |
|
| 208 | - $key = sanitize_key( $key ); |
|
| 198 | + /** |
|
| 199 | + * Check a session variable is set or not. |
|
| 200 | + * |
|
| 201 | + * @since 1.0.0 |
|
| 202 | + * |
|
| 203 | + * @param string $key Session key. |
|
| 204 | + * @param integer $value Session variable. |
|
| 205 | + * @return string Session variable. |
|
| 206 | + */ |
|
| 207 | + public function is_set( $key ) { |
|
| 208 | + $key = sanitize_key( $key ); |
|
| 209 | 209 | |
| 210 | - if ( empty( $key ) ) { |
|
| 211 | - return false; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - if ( isset( $this->session[ $key ] ) ) { |
|
| 215 | - return true; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - return false; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * Force the cookie expiration variant time to 23 hours |
|
| 223 | - * |
|
| 224 | - * @access public |
|
| 225 | - * @since 1.0.0 |
|
| 226 | - * @param int $exp Default expiration (1 hour) |
|
| 227 | - * @return int |
|
| 228 | - */ |
|
| 229 | - public function set_expiration_variant_time( $exp ) { |
|
| 230 | - return ( 30 * 60 * 23 ); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Force the cookie expiration time to 24 hours |
|
| 235 | - * |
|
| 236 | - * @access public |
|
| 237 | - * @since 1.0.0 |
|
| 238 | - * @param int $exp Default expiration (1 hour) |
|
| 239 | - * @return int |
|
| 240 | - */ |
|
| 241 | - public function set_expiration_time( $exp ) { |
|
| 242 | - return ( 30 * 60 * 24 ); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * Starts a new session if one hasn't started yet. |
|
| 247 | - * |
|
| 248 | - * @return boolean |
|
| 249 | - * Checks to see if the server supports PHP sessions |
|
| 250 | - * or if the WPINV_USE_PHP_SESSIONS constant is defined |
|
| 251 | - * |
|
| 252 | - * @access public |
|
| 253 | - * @since 1.0.0 |
|
| 254 | - * @return boolean $ret True if we are using PHP sessions, false otherwise |
|
| 255 | - */ |
|
| 256 | - public function use_php_sessions() { |
|
| 257 | - $ret = false; |
|
| 258 | - |
|
| 259 | - // If the database variable is already set, no need to run autodetection |
|
| 260 | - $wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' ); |
|
| 261 | - |
|
| 262 | - if (!$wpinv_use_php_sessions ) { |
|
| 263 | - // Attempt to detect if the server supports PHP sessions |
|
| 264 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 265 | - $this->set( 'wpinv_use_php_sessions', 1 ); |
|
| 210 | + if ( empty( $key ) ) { |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + if ( isset( $this->session[ $key ] ) ) { |
|
| 215 | + return true; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + return false; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * Force the cookie expiration variant time to 23 hours |
|
| 223 | + * |
|
| 224 | + * @access public |
|
| 225 | + * @since 1.0.0 |
|
| 226 | + * @param int $exp Default expiration (1 hour) |
|
| 227 | + * @return int |
|
| 228 | + */ |
|
| 229 | + public function set_expiration_variant_time( $exp ) { |
|
| 230 | + return ( 30 * 60 * 23 ); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Force the cookie expiration time to 24 hours |
|
| 235 | + * |
|
| 236 | + * @access public |
|
| 237 | + * @since 1.0.0 |
|
| 238 | + * @param int $exp Default expiration (1 hour) |
|
| 239 | + * @return int |
|
| 240 | + */ |
|
| 241 | + public function set_expiration_time( $exp ) { |
|
| 242 | + return ( 30 * 60 * 24 ); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * Starts a new session if one hasn't started yet. |
|
| 247 | + * |
|
| 248 | + * @return boolean |
|
| 249 | + * Checks to see if the server supports PHP sessions |
|
| 250 | + * or if the WPINV_USE_PHP_SESSIONS constant is defined |
|
| 251 | + * |
|
| 252 | + * @access public |
|
| 253 | + * @since 1.0.0 |
|
| 254 | + * @return boolean $ret True if we are using PHP sessions, false otherwise |
|
| 255 | + */ |
|
| 256 | + public function use_php_sessions() { |
|
| 257 | + $ret = false; |
|
| 258 | + |
|
| 259 | + // If the database variable is already set, no need to run autodetection |
|
| 260 | + $wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' ); |
|
| 261 | + |
|
| 262 | + if (!$wpinv_use_php_sessions ) { |
|
| 263 | + // Attempt to detect if the server supports PHP sessions |
|
| 264 | + if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 265 | + $this->set( 'wpinv_use_php_sessions', 1 ); |
|
| 266 | 266 | |
| 267 | - if ( $this->get( 'wpinv_use_php_sessions' ) ) { |
|
| 268 | - $ret = true; |
|
| 269 | - |
|
| 270 | - // Set the database option |
|
| 271 | - update_option( 'wpinv_use_php_sessions', true ); |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - } else { |
|
| 275 | - $ret = $wpinv_use_php_sessions; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - // Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant |
|
| 279 | - if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) { |
|
| 280 | - $ret = true; |
|
| 281 | - } else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) { |
|
| 282 | - $ret = false; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - return (bool) apply_filters( 'wpinv_use_php_sessions', $ret ); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Starts a new session if one hasn't started yet. |
|
| 290 | - */ |
|
| 291 | - public function maybe_start_session() { |
|
| 292 | - if ( !session_id() && !headers_sent() ) { |
|
| 293 | - session_start(); |
|
| 294 | - } |
|
| 295 | - } |
|
| 267 | + if ( $this->get( 'wpinv_use_php_sessions' ) ) { |
|
| 268 | + $ret = true; |
|
| 269 | + |
|
| 270 | + // Set the database option |
|
| 271 | + update_option( 'wpinv_use_php_sessions', true ); |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + } else { |
|
| 275 | + $ret = $wpinv_use_php_sessions; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + // Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant |
|
| 279 | + if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) { |
|
| 280 | + $ret = true; |
|
| 281 | + } else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) { |
|
| 282 | + $ret = false; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + return (bool) apply_filters( 'wpinv_use_php_sessions', $ret ); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Starts a new session if one hasn't started yet. |
|
| 290 | + */ |
|
| 291 | + public function maybe_start_session() { |
|
| 292 | + if ( !session_id() && !headers_sent() ) { |
|
| 293 | + session_start(); |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | global $wpi_session; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | const EXCEPTION_CURL = 10; |
| 41 | 41 | |
| 42 | 42 | private $ch; |
| 43 | - private $login; |
|
| 43 | + private $login; |
|
| 44 | 44 | private $response; |
| 45 | 45 | private $response_xml; |
| 46 | 46 | private $results; |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | private $url; |
| 49 | 49 | private $xml; |
| 50 | 50 | |
| 51 | - public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER) |
|
| 52 | - { |
|
| 53 | - $login = trim($login); |
|
| 51 | + public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER) |
|
| 52 | + { |
|
| 53 | + $login = trim($login); |
|
| 54 | 54 | $transkey = trim($transkey); |
| 55 | 55 | if (empty($login) || empty($transkey)) |
| 56 | 56 | { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $subdomain = ($test) ? 'apitest' : 'api'; |
| 65 | 65 | $this->url = 'https://' . $subdomain . '.authorize.net/xml/v1/request.api'; |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * remove XML response namespaces |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function __toString() |
|
| 82 | - { |
|
| 83 | - $output = ''; |
|
| 81 | + public function __toString() |
|
| 82 | + { |
|
| 83 | + $output = ''; |
|
| 84 | 84 | $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n"; |
| 85 | 85 | $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n"; |
| 86 | 86 | $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n"; |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | $output .= '</table>'; |
| 118 | 118 | |
| 119 | 119 | return $output; |
| 120 | - } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - public function __destruct() |
|
| 122 | + public function __destruct() |
|
| 123 | 123 | { |
| 124 | 124 | if (isset($this->ch)) |
| 125 | 125 | { |
@@ -128,31 +128,31 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public function __get($var) |
| 131 | - { |
|
| 132 | - return $this->response_xml->$var; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - public function __set($key, $value) |
|
| 136 | - { |
|
| 137 | - trigger_error('You cannot set parameters directly in ' . __CLASS__ . '.', E_USER_WARNING); |
|
| 138 | - return false; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - public function __call($api_call, $args) |
|
| 142 | - { |
|
| 143 | - $this->xml = new SimpleXMLElement('<' . $api_call . '></' . $api_call . '>'); |
|
| 131 | + { |
|
| 132 | + return $this->response_xml->$var; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + public function __set($key, $value) |
|
| 136 | + { |
|
| 137 | + trigger_error('You cannot set parameters directly in ' . __CLASS__ . '.', E_USER_WARNING); |
|
| 138 | + return false; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + public function __call($api_call, $args) |
|
| 142 | + { |
|
| 143 | + $this->xml = new SimpleXMLElement('<' . $api_call . '></' . $api_call . '>'); |
|
| 144 | 144 | $this->xml->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'); |
| 145 | - $merch_auth = $this->xml->addChild('merchantAuthentication'); |
|
| 145 | + $merch_auth = $this->xml->addChild('merchantAuthentication'); |
|
| 146 | 146 | $merch_auth->addChild('name', $this->login); |
| 147 | - $merch_auth->addChild('transactionKey', $this->transkey); |
|
| 147 | + $merch_auth->addChild('transactionKey', $this->transkey); |
|
| 148 | 148 | |
| 149 | - $this->setParameters($this->xml, $args[0]); |
|
| 150 | - $this->process(); |
|
| 151 | - } |
|
| 149 | + $this->setParameters($this->xml, $args[0]); |
|
| 150 | + $this->process(); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - private function setParameters($xml, $array) |
|
| 154 | - { |
|
| 155 | - if (is_array($array)) |
|
| 153 | + private function setParameters($xml, $array) |
|
| 154 | + { |
|
| 155 | + if (is_array($array)) |
|
| 156 | 156 | { |
| 157 | 157 | $first = true; |
| 158 | 158 | foreach ($array as $key => $value) |
@@ -184,34 +184,34 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - private function process() |
|
| 190 | - { |
|
| 191 | - $this->xml = $this->xml->asXML(); |
|
| 189 | + private function process() |
|
| 190 | + { |
|
| 191 | + $this->xml = $this->xml->asXML(); |
|
| 192 | 192 | |
| 193 | - $this->ch = curl_init(); |
|
| 193 | + $this->ch = curl_init(); |
|
| 194 | 194 | curl_setopt($this->ch, CURLOPT_URL, $this->url); |
| 195 | - curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 196 | - curl_setopt($this->ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); |
|
| 197 | - curl_setopt($this->ch, CURLOPT_HEADER, 0); |
|
| 198 | - curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->xml); |
|
| 199 | - curl_setopt($this->ch, CURLOPT_POST, 1); |
|
| 200 | - curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2); |
|
| 201 | - curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem'); |
|
| 195 | + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 196 | + curl_setopt($this->ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); |
|
| 197 | + curl_setopt($this->ch, CURLOPT_HEADER, 0); |
|
| 198 | + curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->xml); |
|
| 199 | + curl_setopt($this->ch, CURLOPT_POST, 1); |
|
| 200 | + curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2); |
|
| 201 | + curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem'); |
|
| 202 | 202 | |
| 203 | 203 | if(($this->response = curl_exec($this->ch)) !== false) |
| 204 | 204 | { |
| 205 | 205 | $this->response_xml = @new SimpleXMLElement($this->response); |
| 206 | 206 | |
| 207 | - curl_close($this->ch); |
|
| 207 | + curl_close($this->ch); |
|
| 208 | 208 | unset($this->ch); |
| 209 | 209 | return; |
| 210 | - } |
|
| 210 | + } |
|
| 211 | 211 | throw new AuthnetXMLException('Connection error: ' . curl_error($this->ch) . ' (' . curl_errno($this->ch) . ')', self::EXCEPTION_CURL); |
| 212 | - } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - public function isSuccessful() |
|
| 214 | + public function isSuccessful() |
|
| 215 | 215 | { |
| 216 | 216 | return $this->response_xml->messages->resultCode == 'Ok'; |
| 217 | 217 | } |
@@ -91,13 +91,13 @@ |
||
| 91 | 91 | return $this->_sendRequest(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * |
|
| 96 | - * |
|
| 97 | - * @param string $response |
|
| 98 | - * |
|
| 99 | - * @return AuthorizeNetARB_Response |
|
| 100 | - */ |
|
| 94 | + /** |
|
| 95 | + * |
|
| 96 | + * |
|
| 97 | + * @param string $response |
|
| 98 | + * |
|
| 99 | + * @return AuthorizeNetARB_Response |
|
| 100 | + */ |
|
| 101 | 101 | protected function _handleResponse($response) |
| 102 | 102 | { |
| 103 | 103 | return new AuthorizeNetARB_Response($response); |
@@ -316,9 +316,9 @@ |
||
| 316 | 316 | return $this->_sendRequest(); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * @return string |
|
| 321 | - */ |
|
| 319 | + /** |
|
| 320 | + * @return string |
|
| 321 | + */ |
|
| 322 | 322 | protected function _getPostUrl() |
| 323 | 323 | { |
| 324 | 324 | return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL); |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | } |
| 77 | 77 | else |
| 78 | 78 | { |
| 79 | - echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']); |
|
| 79 | + echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | function wpinv_get_default_country() { |
| 16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 17 | 17 | |
| 18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
| 18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function wpinv_is_base_country( $country ) { |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function wpinv_get_default_state() { |
| 43 | - $state = wpinv_get_option( 'default_state', false ); |
|
| 43 | + $state = wpinv_get_option( 'default_state', false ); |
|
| 44 | 44 | |
| 45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
| 45 | + return apply_filters( 'wpinv_default_state', $state ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -115,260 +115,260 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function wpinv_get_country_list( $first_empty = false ) { |
| 118 | - $countries = array( |
|
| 119 | - 'US' => __('United States', 'invoicing'), |
|
| 120 | - 'CA' => __('Canada', 'invoicing'), |
|
| 121 | - 'GB' => __('United Kingdom', 'invoicing'), |
|
| 122 | - 'AF' => __('Afghanistan', 'invoicing'), |
|
| 123 | - 'AX' => __('Aland Islands', 'invoicing'), |
|
| 124 | - 'AL' => __('Albania', 'invoicing'), |
|
| 125 | - 'DZ' => __('Algeria', 'invoicing'), |
|
| 126 | - 'AS' => __('American Samoa', 'invoicing'), |
|
| 127 | - 'AD' => __('Andorra', 'invoicing'), |
|
| 128 | - 'AO' => __('Angola', 'invoicing'), |
|
| 129 | - 'AI' => __('Anguilla', 'invoicing'), |
|
| 130 | - 'AQ' => __('Antarctica', 'invoicing'), |
|
| 131 | - 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
| 132 | - 'AR' => __('Argentina', 'invoicing'), |
|
| 133 | - 'AM' => __('Armenia', 'invoicing'), |
|
| 134 | - 'AW' => __('Aruba', 'invoicing'), |
|
| 135 | - 'AU' => __('Australia', 'invoicing'), |
|
| 136 | - 'AT' => __('Austria', 'invoicing'), |
|
| 137 | - 'AZ' => __('Azerbaijan', 'invoicing'), |
|
| 138 | - 'BS' => __('Bahamas', 'invoicing'), |
|
| 139 | - 'BH' => __('Bahrain', 'invoicing'), |
|
| 140 | - 'BD' => __('Bangladesh', 'invoicing'), |
|
| 141 | - 'BB' => __('Barbados', 'invoicing'), |
|
| 142 | - 'BY' => __('Belarus', 'invoicing'), |
|
| 143 | - 'BE' => __('Belgium', 'invoicing'), |
|
| 144 | - 'BZ' => __('Belize', 'invoicing'), |
|
| 145 | - 'BJ' => __('Benin', 'invoicing'), |
|
| 146 | - 'BM' => __('Bermuda', 'invoicing'), |
|
| 147 | - 'BT' => __('Bhutan', 'invoicing'), |
|
| 148 | - 'BO' => __('Bolivia', 'invoicing'), |
|
| 149 | - 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
| 150 | - 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
| 151 | - 'BW' => __('Botswana', 'invoicing'), |
|
| 152 | - 'BV' => __('Bouvet Island', 'invoicing'), |
|
| 153 | - 'BR' => __('Brazil', 'invoicing'), |
|
| 154 | - 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
| 155 | - 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
| 156 | - 'BG' => __('Bulgaria', 'invoicing'), |
|
| 157 | - 'BF' => __('Burkina Faso', 'invoicing'), |
|
| 158 | - 'BI' => __('Burundi', 'invoicing'), |
|
| 159 | - 'KH' => __('Cambodia', 'invoicing'), |
|
| 160 | - 'CM' => __('Cameroon', 'invoicing'), |
|
| 161 | - 'CV' => __('Cape Verde', 'invoicing'), |
|
| 162 | - 'KY' => __('Cayman Islands', 'invoicing'), |
|
| 163 | - 'CF' => __('Central African Republic', 'invoicing'), |
|
| 164 | - 'TD' => __('Chad', 'invoicing'), |
|
| 165 | - 'CL' => __('Chile', 'invoicing'), |
|
| 166 | - 'CN' => __('China', 'invoicing'), |
|
| 167 | - 'CX' => __('Christmas Island', 'invoicing'), |
|
| 168 | - 'CC' => __('Cocos Islands', 'invoicing'), |
|
| 169 | - 'CO' => __('Colombia', 'invoicing'), |
|
| 170 | - 'KM' => __('Comoros', 'invoicing'), |
|
| 171 | - 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
| 172 | - 'CG' => __('Congo, Republic of', 'invoicing'), |
|
| 173 | - 'CK' => __('Cook Islands', 'invoicing'), |
|
| 174 | - 'CR' => __('Costa Rica', 'invoicing'), |
|
| 175 | - 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
| 176 | - 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
| 177 | - 'CU' => __('Cuba', 'invoicing'), |
|
| 178 | - 'CW' => __('CuraÇao', 'invoicing'), |
|
| 179 | - 'CY' => __('Cyprus', 'invoicing'), |
|
| 180 | - 'CZ' => __('Czech Republic', 'invoicing'), |
|
| 181 | - 'DK' => __('Denmark', 'invoicing'), |
|
| 182 | - 'DJ' => __('Djibouti', 'invoicing'), |
|
| 183 | - 'DM' => __('Dominica', 'invoicing'), |
|
| 184 | - 'DO' => __('Dominican Republic', 'invoicing'), |
|
| 185 | - 'TP' => __('East Timor', 'invoicing'), |
|
| 186 | - 'EC' => __('Ecuador', 'invoicing'), |
|
| 187 | - 'EG' => __('Egypt', 'invoicing'), |
|
| 188 | - 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
| 189 | - 'SV' => __('El Salvador', 'invoicing'), |
|
| 190 | - 'ER' => __('Eritrea', 'invoicing'), |
|
| 191 | - 'EE' => __('Estonia', 'invoicing'), |
|
| 192 | - 'ET' => __('Ethiopia', 'invoicing'), |
|
| 193 | - 'FK' => __('Falkland Islands', 'invoicing'), |
|
| 194 | - 'FO' => __('Faroe Islands', 'invoicing'), |
|
| 195 | - 'FJ' => __('Fiji', 'invoicing'), |
|
| 196 | - 'FI' => __('Finland', 'invoicing'), |
|
| 197 | - 'FR' => __('France', 'invoicing'), |
|
| 198 | - 'GF' => __('French Guiana', 'invoicing'), |
|
| 199 | - 'PF' => __('French Polynesia', 'invoicing'), |
|
| 200 | - 'TF' => __('French Southern Territories', 'invoicing'), |
|
| 201 | - 'GA' => __('Gabon', 'invoicing'), |
|
| 202 | - 'GM' => __('Gambia', 'invoicing'), |
|
| 203 | - 'GE' => __('Georgia', 'invoicing'), |
|
| 204 | - 'DE' => __('Germany', 'invoicing'), |
|
| 205 | - 'GR' => __('Greece', 'invoicing'), |
|
| 206 | - 'GH' => __('Ghana', 'invoicing'), |
|
| 207 | - 'GI' => __('Gibraltar', 'invoicing'), |
|
| 208 | - 'GL' => __('Greenland', 'invoicing'), |
|
| 209 | - 'GD' => __('Grenada', 'invoicing'), |
|
| 210 | - 'GP' => __('Guadeloupe', 'invoicing'), |
|
| 211 | - 'GU' => __('Guam', 'invoicing'), |
|
| 212 | - 'GT' => __('Guatemala', 'invoicing'), |
|
| 213 | - 'GG' => __('Guernsey', 'invoicing'), |
|
| 214 | - 'GN' => __('Guinea', 'invoicing'), |
|
| 215 | - 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
| 216 | - 'GY' => __('Guyana', 'invoicing'), |
|
| 217 | - 'HT' => __('Haiti', 'invoicing'), |
|
| 218 | - 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
| 219 | - 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
| 220 | - 'HN' => __('Honduras', 'invoicing'), |
|
| 221 | - 'HK' => __('Hong Kong', 'invoicing'), |
|
| 222 | - 'HU' => __('Hungary', 'invoicing'), |
|
| 223 | - 'IS' => __('Iceland', 'invoicing'), |
|
| 224 | - 'IN' => __('India', 'invoicing'), |
|
| 225 | - 'ID' => __('Indonesia', 'invoicing'), |
|
| 226 | - 'IR' => __('Iran', 'invoicing'), |
|
| 227 | - 'IQ' => __('Iraq', 'invoicing'), |
|
| 228 | - 'IE' => __('Ireland', 'invoicing'), |
|
| 229 | - 'IM' => __('Isle of Man', 'invoicing'), |
|
| 230 | - 'IL' => __('Israel', 'invoicing'), |
|
| 231 | - 'IT' => __('Italy', 'invoicing'), |
|
| 232 | - 'JM' => __('Jamaica', 'invoicing'), |
|
| 233 | - 'JP' => __('Japan', 'invoicing'), |
|
| 234 | - 'JE' => __('Jersey', 'invoicing'), |
|
| 235 | - 'JO' => __('Jordan', 'invoicing'), |
|
| 236 | - 'KZ' => __('Kazakhstan', 'invoicing'), |
|
| 237 | - 'KE' => __('Kenya', 'invoicing'), |
|
| 238 | - 'KI' => __('Kiribati', 'invoicing'), |
|
| 239 | - 'KW' => __('Kuwait', 'invoicing'), |
|
| 240 | - 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
| 241 | - 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
| 242 | - 'LV' => __('Latvia', 'invoicing'), |
|
| 243 | - 'LB' => __('Lebanon', 'invoicing'), |
|
| 244 | - 'LS' => __('Lesotho', 'invoicing'), |
|
| 245 | - 'LR' => __('Liberia', 'invoicing'), |
|
| 246 | - 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
| 247 | - 'LI' => __('Liechtenstein', 'invoicing'), |
|
| 248 | - 'LT' => __('Lithuania', 'invoicing'), |
|
| 249 | - 'LU' => __('Luxembourg', 'invoicing'), |
|
| 250 | - 'MO' => __('Macau', 'invoicing'), |
|
| 251 | - 'MK' => __('Macedonia', 'invoicing'), |
|
| 252 | - 'MG' => __('Madagascar', 'invoicing'), |
|
| 253 | - 'MW' => __('Malawi', 'invoicing'), |
|
| 254 | - 'MY' => __('Malaysia', 'invoicing'), |
|
| 255 | - 'MV' => __('Maldives', 'invoicing'), |
|
| 256 | - 'ML' => __('Mali', 'invoicing'), |
|
| 257 | - 'MT' => __('Malta', 'invoicing'), |
|
| 258 | - 'MH' => __('Marshall Islands', 'invoicing'), |
|
| 259 | - 'MQ' => __('Martinique', 'invoicing'), |
|
| 260 | - 'MR' => __('Mauritania', 'invoicing'), |
|
| 261 | - 'MU' => __('Mauritius', 'invoicing'), |
|
| 262 | - 'YT' => __('Mayotte', 'invoicing'), |
|
| 263 | - 'MX' => __('Mexico', 'invoicing'), |
|
| 264 | - 'FM' => __('Micronesia', 'invoicing'), |
|
| 265 | - 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
| 266 | - 'MC' => __('Monaco', 'invoicing'), |
|
| 267 | - 'MN' => __('Mongolia', 'invoicing'), |
|
| 268 | - 'ME' => __('Montenegro', 'invoicing'), |
|
| 269 | - 'MS' => __('Montserrat', 'invoicing'), |
|
| 270 | - 'MA' => __('Morocco', 'invoicing'), |
|
| 271 | - 'MZ' => __('Mozambique', 'invoicing'), |
|
| 272 | - 'MM' => __('Myanmar', 'invoicing'), |
|
| 273 | - 'NA' => __('Namibia', 'invoicing'), |
|
| 274 | - 'NR' => __('Nauru', 'invoicing'), |
|
| 275 | - 'NP' => __('Nepal', 'invoicing'), |
|
| 276 | - 'NL' => __('Netherlands', 'invoicing'), |
|
| 277 | - 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
| 278 | - 'NC' => __('New Caledonia', 'invoicing'), |
|
| 279 | - 'NZ' => __('New Zealand', 'invoicing'), |
|
| 280 | - 'NI' => __('Nicaragua', 'invoicing'), |
|
| 281 | - 'NE' => __('Niger', 'invoicing'), |
|
| 282 | - 'NG' => __('Nigeria', 'invoicing'), |
|
| 283 | - 'NU' => __('Niue', 'invoicing'), |
|
| 284 | - 'NF' => __('Norfolk Island', 'invoicing'), |
|
| 285 | - 'KP' => __('North Korea', 'invoicing'), |
|
| 286 | - 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
| 287 | - 'NO' => __('Norway', 'invoicing'), |
|
| 288 | - 'OM' => __('Oman', 'invoicing'), |
|
| 289 | - 'PK' => __('Pakistan', 'invoicing'), |
|
| 290 | - 'PW' => __('Palau', 'invoicing'), |
|
| 291 | - 'PS' => __('Palestinian Territories', 'invoicing'), |
|
| 292 | - 'PA' => __('Panama', 'invoicing'), |
|
| 293 | - 'PG' => __('Papua New Guinea', 'invoicing'), |
|
| 294 | - 'PY' => __('Paraguay', 'invoicing'), |
|
| 295 | - 'PE' => __('Peru', 'invoicing'), |
|
| 296 | - 'PH' => __('Phillipines', 'invoicing'), |
|
| 297 | - 'PN' => __('Pitcairn Island', 'invoicing'), |
|
| 298 | - 'PL' => __('Poland', 'invoicing'), |
|
| 299 | - 'PT' => __('Portugal', 'invoicing'), |
|
| 300 | - 'PR' => __('Puerto Rico', 'invoicing'), |
|
| 301 | - 'QA' => __('Qatar', 'invoicing'), |
|
| 302 | - 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
| 303 | - 'RE' => __('Reunion Island', 'invoicing'), |
|
| 304 | - 'RO' => __('Romania', 'invoicing'), |
|
| 305 | - 'RU' => __('Russian Federation', 'invoicing'), |
|
| 306 | - 'RW' => __('Rwanda', 'invoicing'), |
|
| 307 | - 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
| 308 | - 'SH' => __('Saint Helena', 'invoicing'), |
|
| 309 | - 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
| 310 | - 'LC' => __('Saint Lucia', 'invoicing'), |
|
| 311 | - 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
| 312 | - 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
| 313 | - 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
| 314 | - 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
| 315 | - 'SM' => __('San Marino', 'invoicing'), |
|
| 316 | - 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
| 317 | - 'SA' => __('Saudi Arabia', 'invoicing'), |
|
| 318 | - 'SN' => __('Senegal', 'invoicing'), |
|
| 319 | - 'RS' => __('Serbia', 'invoicing'), |
|
| 320 | - 'SC' => __('Seychelles', 'invoicing'), |
|
| 321 | - 'SL' => __('Sierra Leone', 'invoicing'), |
|
| 322 | - 'SG' => __('Singapore', 'invoicing'), |
|
| 323 | - 'SK' => __('Slovak Republic', 'invoicing'), |
|
| 324 | - 'SI' => __('Slovenia', 'invoicing'), |
|
| 325 | - 'SB' => __('Solomon Islands', 'invoicing'), |
|
| 326 | - 'SO' => __('Somalia', 'invoicing'), |
|
| 327 | - 'ZA' => __('South Africa', 'invoicing'), |
|
| 328 | - 'GS' => __('South Georgia', 'invoicing'), |
|
| 329 | - 'KR' => __('South Korea', 'invoicing'), |
|
| 330 | - 'SS' => __('South Sudan', 'invoicing'), |
|
| 331 | - 'ES' => __('Spain', 'invoicing'), |
|
| 332 | - 'LK' => __('Sri Lanka', 'invoicing'), |
|
| 333 | - 'SD' => __('Sudan', 'invoicing'), |
|
| 334 | - 'SR' => __('Suriname', 'invoicing'), |
|
| 335 | - 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
| 336 | - 'SZ' => __('Swaziland', 'invoicing'), |
|
| 337 | - 'SE' => __('Sweden', 'invoicing'), |
|
| 338 | - 'CH' => __('Switzerland', 'invoicing'), |
|
| 339 | - 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
| 340 | - 'TW' => __('Taiwan', 'invoicing'), |
|
| 341 | - 'TJ' => __('Tajikistan', 'invoicing'), |
|
| 342 | - 'TZ' => __('Tanzania', 'invoicing'), |
|
| 343 | - 'TH' => __('Thailand', 'invoicing'), |
|
| 344 | - 'TL' => __('Timor-Leste', 'invoicing'), |
|
| 345 | - 'TG' => __('Togo', 'invoicing'), |
|
| 346 | - 'TK' => __('Tokelau', 'invoicing'), |
|
| 347 | - 'TO' => __('Tonga', 'invoicing'), |
|
| 348 | - 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
| 349 | - 'TN' => __('Tunisia', 'invoicing'), |
|
| 350 | - 'TR' => __('Turkey', 'invoicing'), |
|
| 351 | - 'TM' => __('Turkmenistan', 'invoicing'), |
|
| 352 | - 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
| 353 | - 'TV' => __('Tuvalu', 'invoicing'), |
|
| 354 | - 'UG' => __('Uganda', 'invoicing'), |
|
| 355 | - 'UA' => __('Ukraine', 'invoicing'), |
|
| 356 | - 'AE' => __('United Arab Emirates', 'invoicing'), |
|
| 357 | - 'UY' => __('Uruguay', 'invoicing'), |
|
| 358 | - 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
| 359 | - 'UZ' => __('Uzbekistan', 'invoicing'), |
|
| 360 | - 'VU' => __('Vanuatu', 'invoicing'), |
|
| 361 | - 'VE' => __('Venezuela', 'invoicing'), |
|
| 362 | - 'VN' => __('Vietnam', 'invoicing'), |
|
| 363 | - 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
| 364 | - 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
| 365 | - 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
| 366 | - 'EH' => __('Western Sahara', 'invoicing'), |
|
| 367 | - 'WS' => __('Western Samoa', 'invoicing'), |
|
| 368 | - 'YE' => __('Yemen', 'invoicing'), |
|
| 369 | - 'ZM' => __('Zambia', 'invoicing'), |
|
| 370 | - 'ZW' => __('Zimbabwe', 'invoicing'), |
|
| 371 | - ); |
|
| 118 | + $countries = array( |
|
| 119 | + 'US' => __('United States', 'invoicing'), |
|
| 120 | + 'CA' => __('Canada', 'invoicing'), |
|
| 121 | + 'GB' => __('United Kingdom', 'invoicing'), |
|
| 122 | + 'AF' => __('Afghanistan', 'invoicing'), |
|
| 123 | + 'AX' => __('Aland Islands', 'invoicing'), |
|
| 124 | + 'AL' => __('Albania', 'invoicing'), |
|
| 125 | + 'DZ' => __('Algeria', 'invoicing'), |
|
| 126 | + 'AS' => __('American Samoa', 'invoicing'), |
|
| 127 | + 'AD' => __('Andorra', 'invoicing'), |
|
| 128 | + 'AO' => __('Angola', 'invoicing'), |
|
| 129 | + 'AI' => __('Anguilla', 'invoicing'), |
|
| 130 | + 'AQ' => __('Antarctica', 'invoicing'), |
|
| 131 | + 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
| 132 | + 'AR' => __('Argentina', 'invoicing'), |
|
| 133 | + 'AM' => __('Armenia', 'invoicing'), |
|
| 134 | + 'AW' => __('Aruba', 'invoicing'), |
|
| 135 | + 'AU' => __('Australia', 'invoicing'), |
|
| 136 | + 'AT' => __('Austria', 'invoicing'), |
|
| 137 | + 'AZ' => __('Azerbaijan', 'invoicing'), |
|
| 138 | + 'BS' => __('Bahamas', 'invoicing'), |
|
| 139 | + 'BH' => __('Bahrain', 'invoicing'), |
|
| 140 | + 'BD' => __('Bangladesh', 'invoicing'), |
|
| 141 | + 'BB' => __('Barbados', 'invoicing'), |
|
| 142 | + 'BY' => __('Belarus', 'invoicing'), |
|
| 143 | + 'BE' => __('Belgium', 'invoicing'), |
|
| 144 | + 'BZ' => __('Belize', 'invoicing'), |
|
| 145 | + 'BJ' => __('Benin', 'invoicing'), |
|
| 146 | + 'BM' => __('Bermuda', 'invoicing'), |
|
| 147 | + 'BT' => __('Bhutan', 'invoicing'), |
|
| 148 | + 'BO' => __('Bolivia', 'invoicing'), |
|
| 149 | + 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
| 150 | + 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
| 151 | + 'BW' => __('Botswana', 'invoicing'), |
|
| 152 | + 'BV' => __('Bouvet Island', 'invoicing'), |
|
| 153 | + 'BR' => __('Brazil', 'invoicing'), |
|
| 154 | + 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
| 155 | + 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
| 156 | + 'BG' => __('Bulgaria', 'invoicing'), |
|
| 157 | + 'BF' => __('Burkina Faso', 'invoicing'), |
|
| 158 | + 'BI' => __('Burundi', 'invoicing'), |
|
| 159 | + 'KH' => __('Cambodia', 'invoicing'), |
|
| 160 | + 'CM' => __('Cameroon', 'invoicing'), |
|
| 161 | + 'CV' => __('Cape Verde', 'invoicing'), |
|
| 162 | + 'KY' => __('Cayman Islands', 'invoicing'), |
|
| 163 | + 'CF' => __('Central African Republic', 'invoicing'), |
|
| 164 | + 'TD' => __('Chad', 'invoicing'), |
|
| 165 | + 'CL' => __('Chile', 'invoicing'), |
|
| 166 | + 'CN' => __('China', 'invoicing'), |
|
| 167 | + 'CX' => __('Christmas Island', 'invoicing'), |
|
| 168 | + 'CC' => __('Cocos Islands', 'invoicing'), |
|
| 169 | + 'CO' => __('Colombia', 'invoicing'), |
|
| 170 | + 'KM' => __('Comoros', 'invoicing'), |
|
| 171 | + 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
| 172 | + 'CG' => __('Congo, Republic of', 'invoicing'), |
|
| 173 | + 'CK' => __('Cook Islands', 'invoicing'), |
|
| 174 | + 'CR' => __('Costa Rica', 'invoicing'), |
|
| 175 | + 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
| 176 | + 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
| 177 | + 'CU' => __('Cuba', 'invoicing'), |
|
| 178 | + 'CW' => __('CuraÇao', 'invoicing'), |
|
| 179 | + 'CY' => __('Cyprus', 'invoicing'), |
|
| 180 | + 'CZ' => __('Czech Republic', 'invoicing'), |
|
| 181 | + 'DK' => __('Denmark', 'invoicing'), |
|
| 182 | + 'DJ' => __('Djibouti', 'invoicing'), |
|
| 183 | + 'DM' => __('Dominica', 'invoicing'), |
|
| 184 | + 'DO' => __('Dominican Republic', 'invoicing'), |
|
| 185 | + 'TP' => __('East Timor', 'invoicing'), |
|
| 186 | + 'EC' => __('Ecuador', 'invoicing'), |
|
| 187 | + 'EG' => __('Egypt', 'invoicing'), |
|
| 188 | + 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
| 189 | + 'SV' => __('El Salvador', 'invoicing'), |
|
| 190 | + 'ER' => __('Eritrea', 'invoicing'), |
|
| 191 | + 'EE' => __('Estonia', 'invoicing'), |
|
| 192 | + 'ET' => __('Ethiopia', 'invoicing'), |
|
| 193 | + 'FK' => __('Falkland Islands', 'invoicing'), |
|
| 194 | + 'FO' => __('Faroe Islands', 'invoicing'), |
|
| 195 | + 'FJ' => __('Fiji', 'invoicing'), |
|
| 196 | + 'FI' => __('Finland', 'invoicing'), |
|
| 197 | + 'FR' => __('France', 'invoicing'), |
|
| 198 | + 'GF' => __('French Guiana', 'invoicing'), |
|
| 199 | + 'PF' => __('French Polynesia', 'invoicing'), |
|
| 200 | + 'TF' => __('French Southern Territories', 'invoicing'), |
|
| 201 | + 'GA' => __('Gabon', 'invoicing'), |
|
| 202 | + 'GM' => __('Gambia', 'invoicing'), |
|
| 203 | + 'GE' => __('Georgia', 'invoicing'), |
|
| 204 | + 'DE' => __('Germany', 'invoicing'), |
|
| 205 | + 'GR' => __('Greece', 'invoicing'), |
|
| 206 | + 'GH' => __('Ghana', 'invoicing'), |
|
| 207 | + 'GI' => __('Gibraltar', 'invoicing'), |
|
| 208 | + 'GL' => __('Greenland', 'invoicing'), |
|
| 209 | + 'GD' => __('Grenada', 'invoicing'), |
|
| 210 | + 'GP' => __('Guadeloupe', 'invoicing'), |
|
| 211 | + 'GU' => __('Guam', 'invoicing'), |
|
| 212 | + 'GT' => __('Guatemala', 'invoicing'), |
|
| 213 | + 'GG' => __('Guernsey', 'invoicing'), |
|
| 214 | + 'GN' => __('Guinea', 'invoicing'), |
|
| 215 | + 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
| 216 | + 'GY' => __('Guyana', 'invoicing'), |
|
| 217 | + 'HT' => __('Haiti', 'invoicing'), |
|
| 218 | + 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
| 219 | + 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
| 220 | + 'HN' => __('Honduras', 'invoicing'), |
|
| 221 | + 'HK' => __('Hong Kong', 'invoicing'), |
|
| 222 | + 'HU' => __('Hungary', 'invoicing'), |
|
| 223 | + 'IS' => __('Iceland', 'invoicing'), |
|
| 224 | + 'IN' => __('India', 'invoicing'), |
|
| 225 | + 'ID' => __('Indonesia', 'invoicing'), |
|
| 226 | + 'IR' => __('Iran', 'invoicing'), |
|
| 227 | + 'IQ' => __('Iraq', 'invoicing'), |
|
| 228 | + 'IE' => __('Ireland', 'invoicing'), |
|
| 229 | + 'IM' => __('Isle of Man', 'invoicing'), |
|
| 230 | + 'IL' => __('Israel', 'invoicing'), |
|
| 231 | + 'IT' => __('Italy', 'invoicing'), |
|
| 232 | + 'JM' => __('Jamaica', 'invoicing'), |
|
| 233 | + 'JP' => __('Japan', 'invoicing'), |
|
| 234 | + 'JE' => __('Jersey', 'invoicing'), |
|
| 235 | + 'JO' => __('Jordan', 'invoicing'), |
|
| 236 | + 'KZ' => __('Kazakhstan', 'invoicing'), |
|
| 237 | + 'KE' => __('Kenya', 'invoicing'), |
|
| 238 | + 'KI' => __('Kiribati', 'invoicing'), |
|
| 239 | + 'KW' => __('Kuwait', 'invoicing'), |
|
| 240 | + 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
| 241 | + 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
| 242 | + 'LV' => __('Latvia', 'invoicing'), |
|
| 243 | + 'LB' => __('Lebanon', 'invoicing'), |
|
| 244 | + 'LS' => __('Lesotho', 'invoicing'), |
|
| 245 | + 'LR' => __('Liberia', 'invoicing'), |
|
| 246 | + 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
| 247 | + 'LI' => __('Liechtenstein', 'invoicing'), |
|
| 248 | + 'LT' => __('Lithuania', 'invoicing'), |
|
| 249 | + 'LU' => __('Luxembourg', 'invoicing'), |
|
| 250 | + 'MO' => __('Macau', 'invoicing'), |
|
| 251 | + 'MK' => __('Macedonia', 'invoicing'), |
|
| 252 | + 'MG' => __('Madagascar', 'invoicing'), |
|
| 253 | + 'MW' => __('Malawi', 'invoicing'), |
|
| 254 | + 'MY' => __('Malaysia', 'invoicing'), |
|
| 255 | + 'MV' => __('Maldives', 'invoicing'), |
|
| 256 | + 'ML' => __('Mali', 'invoicing'), |
|
| 257 | + 'MT' => __('Malta', 'invoicing'), |
|
| 258 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
| 259 | + 'MQ' => __('Martinique', 'invoicing'), |
|
| 260 | + 'MR' => __('Mauritania', 'invoicing'), |
|
| 261 | + 'MU' => __('Mauritius', 'invoicing'), |
|
| 262 | + 'YT' => __('Mayotte', 'invoicing'), |
|
| 263 | + 'MX' => __('Mexico', 'invoicing'), |
|
| 264 | + 'FM' => __('Micronesia', 'invoicing'), |
|
| 265 | + 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
| 266 | + 'MC' => __('Monaco', 'invoicing'), |
|
| 267 | + 'MN' => __('Mongolia', 'invoicing'), |
|
| 268 | + 'ME' => __('Montenegro', 'invoicing'), |
|
| 269 | + 'MS' => __('Montserrat', 'invoicing'), |
|
| 270 | + 'MA' => __('Morocco', 'invoicing'), |
|
| 271 | + 'MZ' => __('Mozambique', 'invoicing'), |
|
| 272 | + 'MM' => __('Myanmar', 'invoicing'), |
|
| 273 | + 'NA' => __('Namibia', 'invoicing'), |
|
| 274 | + 'NR' => __('Nauru', 'invoicing'), |
|
| 275 | + 'NP' => __('Nepal', 'invoicing'), |
|
| 276 | + 'NL' => __('Netherlands', 'invoicing'), |
|
| 277 | + 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
| 278 | + 'NC' => __('New Caledonia', 'invoicing'), |
|
| 279 | + 'NZ' => __('New Zealand', 'invoicing'), |
|
| 280 | + 'NI' => __('Nicaragua', 'invoicing'), |
|
| 281 | + 'NE' => __('Niger', 'invoicing'), |
|
| 282 | + 'NG' => __('Nigeria', 'invoicing'), |
|
| 283 | + 'NU' => __('Niue', 'invoicing'), |
|
| 284 | + 'NF' => __('Norfolk Island', 'invoicing'), |
|
| 285 | + 'KP' => __('North Korea', 'invoicing'), |
|
| 286 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
| 287 | + 'NO' => __('Norway', 'invoicing'), |
|
| 288 | + 'OM' => __('Oman', 'invoicing'), |
|
| 289 | + 'PK' => __('Pakistan', 'invoicing'), |
|
| 290 | + 'PW' => __('Palau', 'invoicing'), |
|
| 291 | + 'PS' => __('Palestinian Territories', 'invoicing'), |
|
| 292 | + 'PA' => __('Panama', 'invoicing'), |
|
| 293 | + 'PG' => __('Papua New Guinea', 'invoicing'), |
|
| 294 | + 'PY' => __('Paraguay', 'invoicing'), |
|
| 295 | + 'PE' => __('Peru', 'invoicing'), |
|
| 296 | + 'PH' => __('Phillipines', 'invoicing'), |
|
| 297 | + 'PN' => __('Pitcairn Island', 'invoicing'), |
|
| 298 | + 'PL' => __('Poland', 'invoicing'), |
|
| 299 | + 'PT' => __('Portugal', 'invoicing'), |
|
| 300 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
| 301 | + 'QA' => __('Qatar', 'invoicing'), |
|
| 302 | + 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
| 303 | + 'RE' => __('Reunion Island', 'invoicing'), |
|
| 304 | + 'RO' => __('Romania', 'invoicing'), |
|
| 305 | + 'RU' => __('Russian Federation', 'invoicing'), |
|
| 306 | + 'RW' => __('Rwanda', 'invoicing'), |
|
| 307 | + 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
| 308 | + 'SH' => __('Saint Helena', 'invoicing'), |
|
| 309 | + 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
| 310 | + 'LC' => __('Saint Lucia', 'invoicing'), |
|
| 311 | + 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
| 312 | + 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
| 313 | + 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
| 314 | + 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
| 315 | + 'SM' => __('San Marino', 'invoicing'), |
|
| 316 | + 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
| 317 | + 'SA' => __('Saudi Arabia', 'invoicing'), |
|
| 318 | + 'SN' => __('Senegal', 'invoicing'), |
|
| 319 | + 'RS' => __('Serbia', 'invoicing'), |
|
| 320 | + 'SC' => __('Seychelles', 'invoicing'), |
|
| 321 | + 'SL' => __('Sierra Leone', 'invoicing'), |
|
| 322 | + 'SG' => __('Singapore', 'invoicing'), |
|
| 323 | + 'SK' => __('Slovak Republic', 'invoicing'), |
|
| 324 | + 'SI' => __('Slovenia', 'invoicing'), |
|
| 325 | + 'SB' => __('Solomon Islands', 'invoicing'), |
|
| 326 | + 'SO' => __('Somalia', 'invoicing'), |
|
| 327 | + 'ZA' => __('South Africa', 'invoicing'), |
|
| 328 | + 'GS' => __('South Georgia', 'invoicing'), |
|
| 329 | + 'KR' => __('South Korea', 'invoicing'), |
|
| 330 | + 'SS' => __('South Sudan', 'invoicing'), |
|
| 331 | + 'ES' => __('Spain', 'invoicing'), |
|
| 332 | + 'LK' => __('Sri Lanka', 'invoicing'), |
|
| 333 | + 'SD' => __('Sudan', 'invoicing'), |
|
| 334 | + 'SR' => __('Suriname', 'invoicing'), |
|
| 335 | + 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
| 336 | + 'SZ' => __('Swaziland', 'invoicing'), |
|
| 337 | + 'SE' => __('Sweden', 'invoicing'), |
|
| 338 | + 'CH' => __('Switzerland', 'invoicing'), |
|
| 339 | + 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
| 340 | + 'TW' => __('Taiwan', 'invoicing'), |
|
| 341 | + 'TJ' => __('Tajikistan', 'invoicing'), |
|
| 342 | + 'TZ' => __('Tanzania', 'invoicing'), |
|
| 343 | + 'TH' => __('Thailand', 'invoicing'), |
|
| 344 | + 'TL' => __('Timor-Leste', 'invoicing'), |
|
| 345 | + 'TG' => __('Togo', 'invoicing'), |
|
| 346 | + 'TK' => __('Tokelau', 'invoicing'), |
|
| 347 | + 'TO' => __('Tonga', 'invoicing'), |
|
| 348 | + 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
| 349 | + 'TN' => __('Tunisia', 'invoicing'), |
|
| 350 | + 'TR' => __('Turkey', 'invoicing'), |
|
| 351 | + 'TM' => __('Turkmenistan', 'invoicing'), |
|
| 352 | + 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
| 353 | + 'TV' => __('Tuvalu', 'invoicing'), |
|
| 354 | + 'UG' => __('Uganda', 'invoicing'), |
|
| 355 | + 'UA' => __('Ukraine', 'invoicing'), |
|
| 356 | + 'AE' => __('United Arab Emirates', 'invoicing'), |
|
| 357 | + 'UY' => __('Uruguay', 'invoicing'), |
|
| 358 | + 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
| 359 | + 'UZ' => __('Uzbekistan', 'invoicing'), |
|
| 360 | + 'VU' => __('Vanuatu', 'invoicing'), |
|
| 361 | + 'VE' => __('Venezuela', 'invoicing'), |
|
| 362 | + 'VN' => __('Vietnam', 'invoicing'), |
|
| 363 | + 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
| 364 | + 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
| 365 | + 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
| 366 | + 'EH' => __('Western Sahara', 'invoicing'), |
|
| 367 | + 'WS' => __('Western Samoa', 'invoicing'), |
|
| 368 | + 'YE' => __('Yemen', 'invoicing'), |
|
| 369 | + 'ZM' => __('Zambia', 'invoicing'), |
|
| 370 | + 'ZW' => __('Zimbabwe', 'invoicing'), |
|
| 371 | + ); |
|
| 372 | 372 | |
| 373 | 373 | if ( $first_empty ) { |
| 374 | 374 | $countries = array_merge( array( '' => '' ), $countries ); |
@@ -1537,30 +1537,30 @@ discard block |
||
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | 1539 | function wpinv_get_states_field() { |
| 1540 | - if( empty( $_POST['country'] ) ) { |
|
| 1541 | - $_POST['country'] = wpinv_get_default_country(); |
|
| 1542 | - } |
|
| 1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 1540 | + if( empty( $_POST['country'] ) ) { |
|
| 1541 | + $_POST['country'] = wpinv_get_default_country(); |
|
| 1542 | + } |
|
| 1543 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 1544 | 1544 | |
| 1545 | - if( !empty( $states ) ) { |
|
| 1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 1545 | + if( !empty( $states ) ) { |
|
| 1546 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 1547 | 1547 | |
| 1548 | 1548 | $args = array( |
| 1549 | - 'name' => $sanitized_field_name, |
|
| 1550 | - 'id' => $sanitized_field_name, |
|
| 1551 | - 'class' => $sanitized_field_name . ' wpinv-select', |
|
| 1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1553 | - 'show_option_all' => false, |
|
| 1554 | - 'show_option_none' => false |
|
| 1555 | - ); |
|
| 1556 | - |
|
| 1557 | - $response = wpinv_html_select( $args ); |
|
| 1558 | - |
|
| 1559 | - } else { |
|
| 1560 | - $response = 'nostates'; |
|
| 1561 | - } |
|
| 1549 | + 'name' => $sanitized_field_name, |
|
| 1550 | + 'id' => $sanitized_field_name, |
|
| 1551 | + 'class' => $sanitized_field_name . ' wpinv-select', |
|
| 1552 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1553 | + 'show_option_all' => false, |
|
| 1554 | + 'show_option_none' => false |
|
| 1555 | + ); |
|
| 1556 | + |
|
| 1557 | + $response = wpinv_html_select( $args ); |
|
| 1558 | + |
|
| 1559 | + } else { |
|
| 1560 | + $response = 'nostates'; |
|
| 1561 | + } |
|
| 1562 | 1562 | |
| 1563 | - return $response; |
|
| 1563 | + return $response; |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
| 218 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 218 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 219 | 219 | return $invoice->get_key(); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -731,20 +731,20 @@ discard block |
||
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | function wpinv_checkout_get_cc_info() { |
| 734 | - $cc_info = array(); |
|
| 735 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 736 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 737 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 738 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 739 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 740 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 741 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 742 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 743 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 744 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 745 | - |
|
| 746 | - // Return cc info |
|
| 747 | - return $cc_info; |
|
| 734 | + $cc_info = array(); |
|
| 735 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 736 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 737 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 738 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 739 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 740 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 741 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 742 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 743 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 744 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 745 | + |
|
| 746 | + // Return cc info |
|
| 747 | + return $cc_info; |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | $required_fields = wpinv_checkout_required_fields(); |
| 943 | 943 | |
| 944 | 944 | // Loop through required fields and show error messages |
| 945 | - if ( !empty( $required_fields ) ) { |
|
| 945 | + if ( !empty( $required_fields ) ) { |
|
| 946 | 946 | foreach ( $required_fields as $field_name => $value ) { |
| 947 | 947 | if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
| 948 | 948 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | function wpinv_get_checkout_session() { |
| 1028 | - global $wpi_session; |
|
| 1028 | + global $wpi_session; |
|
| 1029 | 1029 | |
| 1030 | 1030 | return $wpi_session->get( 'wpinv_checkout' ); |
| 1031 | 1031 | } |
@@ -1376,47 +1376,47 @@ discard block |
||
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | function wpinv_get_invoice_id_by_key( $key ) { |
| 1379 | - global $wpdb; |
|
| 1379 | + global $wpdb; |
|
| 1380 | 1380 | |
| 1381 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1381 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1382 | 1382 | |
| 1383 | - if ( $invoice_id != NULL ) |
|
| 1384 | - return $invoice_id; |
|
| 1383 | + if ( $invoice_id != NULL ) |
|
| 1384 | + return $invoice_id; |
|
| 1385 | 1385 | |
| 1386 | - return 0; |
|
| 1386 | + return 0; |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
| 1390 | - $return = false; |
|
| 1390 | + $return = false; |
|
| 1391 | 1391 | |
| 1392 | - if ( empty( $invoice_key ) ) { |
|
| 1393 | - return $return; |
|
| 1394 | - } |
|
| 1392 | + if ( empty( $invoice_key ) ) { |
|
| 1393 | + return $return; |
|
| 1394 | + } |
|
| 1395 | 1395 | |
| 1396 | - global $wpinv_receipt_args; |
|
| 1396 | + global $wpinv_receipt_args; |
|
| 1397 | 1397 | |
| 1398 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1399 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1400 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 1401 | - } |
|
| 1398 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1399 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1400 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 1401 | + } |
|
| 1402 | 1402 | |
| 1403 | - $user_id = (int) wpinv_get_user_id( $wpinv_receipt_args['id'] ); |
|
| 1403 | + $user_id = (int) wpinv_get_user_id( $wpinv_receipt_args['id'] ); |
|
| 1404 | 1404 | $invoice_meta = wpinv_get_invoice_meta( $wpinv_receipt_args['id'] ); |
| 1405 | 1405 | |
| 1406 | - if ( is_user_logged_in() ) { |
|
| 1407 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 1408 | - $return = true; |
|
| 1409 | - } |
|
| 1410 | - } |
|
| 1406 | + if ( is_user_logged_in() ) { |
|
| 1407 | + if ( $user_id === (int) get_current_user_id() ) { |
|
| 1408 | + $return = true; |
|
| 1409 | + } |
|
| 1410 | + } |
|
| 1411 | 1411 | |
| 1412 | - $session = wpinv_get_checkout_session(); |
|
| 1413 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 1414 | - if ( $session['invoice_key'] === $invoice_meta['key'] ) { |
|
| 1415 | - $return = true; |
|
| 1416 | - } |
|
| 1417 | - } |
|
| 1412 | + $session = wpinv_get_checkout_session(); |
|
| 1413 | + if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 1414 | + if ( $session['invoice_key'] === $invoice_meta['key'] ) { |
|
| 1415 | + $return = true; |
|
| 1416 | + } |
|
| 1417 | + } |
|
| 1418 | 1418 | |
| 1419 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 1419 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | 1422 | function wpinv_pay_for_invoice() { |
@@ -117,29 +117,29 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 119 | 119 | if ( ! empty( $args ) && is_array( $args ) ) { |
| 120 | - extract( $args ); |
|
| 121 | - } |
|
| 120 | + extract( $args ); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 124 | - if ( ! file_exists( $located ) ) { |
|
| 123 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 124 | + if ( ! file_exists( $located ) ) { |
|
| 125 | 125 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
| 126 | - return; |
|
| 127 | - } |
|
| 126 | + return; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - // Allow 3rd party plugin filter template file from their plugin. |
|
| 130 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 129 | + // Allow 3rd party plugin filter template file from their plugin. |
|
| 130 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 131 | 131 | |
| 132 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 132 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 133 | 133 | |
| 134 | - include( $located ); |
|
| 134 | + include( $located ); |
|
| 135 | 135 | |
| 136 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 136 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 140 | - ob_start(); |
|
| 141 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | - return ob_get_clean(); |
|
| 140 | + ob_start(); |
|
| 141 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | + return ob_get_clean(); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -169,120 +169,120 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 172 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 172 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 173 | 173 | |
| 174 | - // Setup possible parts |
|
| 175 | - $templates = array(); |
|
| 176 | - if ( isset( $name ) ) |
|
| 177 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 178 | - $templates[] = $slug . '.php'; |
|
| 174 | + // Setup possible parts |
|
| 175 | + $templates = array(); |
|
| 176 | + if ( isset( $name ) ) |
|
| 177 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 178 | + $templates[] = $slug . '.php'; |
|
| 179 | 179 | |
| 180 | - // Allow template parts to be filtered |
|
| 181 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 180 | + // Allow template parts to be filtered |
|
| 181 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 182 | 182 | |
| 183 | - // Return the part that is found |
|
| 184 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 183 | + // Return the part that is found |
|
| 184 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
| 188 | - // No file found yet |
|
| 189 | - $located = false; |
|
| 188 | + // No file found yet |
|
| 189 | + $located = false; |
|
| 190 | 190 | |
| 191 | - // Try to find a template file |
|
| 192 | - foreach ( (array)$template_names as $template_name ) { |
|
| 191 | + // Try to find a template file |
|
| 192 | + foreach ( (array)$template_names as $template_name ) { |
|
| 193 | 193 | |
| 194 | - // Continue if template is empty |
|
| 195 | - if ( empty( $template_name ) ) |
|
| 196 | - continue; |
|
| 194 | + // Continue if template is empty |
|
| 195 | + if ( empty( $template_name ) ) |
|
| 196 | + continue; |
|
| 197 | 197 | |
| 198 | - // Trim off any slashes from the template name |
|
| 199 | - $template_name = ltrim( $template_name, '/' ); |
|
| 198 | + // Trim off any slashes from the template name |
|
| 199 | + $template_name = ltrim( $template_name, '/' ); |
|
| 200 | 200 | |
| 201 | - // try locating this template file by looping through the template paths |
|
| 202 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 201 | + // try locating this template file by looping through the template paths |
|
| 202 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 203 | 203 | |
| 204 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 205 | - $located = $template_path . $template_name; |
|
| 206 | - break; |
|
| 207 | - } |
|
| 208 | - } |
|
| 204 | + if( file_exists( $template_path . $template_name ) ) { |
|
| 205 | + $located = $template_path . $template_name; |
|
| 206 | + break; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - if( !empty( $located ) ) { |
|
| 211 | - break; |
|
| 212 | - } |
|
| 213 | - } |
|
| 210 | + if( !empty( $located ) ) { |
|
| 211 | + break; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 216 | - load_template( $located, $require_once ); |
|
| 215 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
| 216 | + load_template( $located, $require_once ); |
|
| 217 | 217 | |
| 218 | - return $located; |
|
| 218 | + return $located; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | function wpinv_get_theme_template_paths() { |
| 222 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 222 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 223 | 223 | |
| 224 | - $file_paths = array( |
|
| 225 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 226 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 227 | - 100 => wpinv_get_templates_dir() |
|
| 228 | - ); |
|
| 224 | + $file_paths = array( |
|
| 225 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 226 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 227 | + 100 => wpinv_get_templates_dir() |
|
| 228 | + ); |
|
| 229 | 229 | |
| 230 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 230 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 231 | 231 | |
| 232 | - // sort the file paths based on priority |
|
| 233 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 232 | + // sort the file paths based on priority |
|
| 233 | + ksort( $file_paths, SORT_NUMERIC ); |
|
| 234 | 234 | |
| 235 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 235 | + return array_map( 'trailingslashit', $file_paths ); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | function wpinv_get_theme_template_dir_name() { |
| 239 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 239 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | function wpinv_checkout_meta_tags() { |
| 243 | 243 | |
| 244 | - $pages = array(); |
|
| 245 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 246 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 247 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 244 | + $pages = array(); |
|
| 245 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
| 246 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 247 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 248 | 248 | |
| 249 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 250 | - return; |
|
| 251 | - } |
|
| 249 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 250 | + return; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 253 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 254 | 254 | } |
| 255 | 255 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
| 256 | 256 | |
| 257 | 257 | function wpinv_add_body_classes( $class ) { |
| 258 | - $classes = (array)$class; |
|
| 258 | + $classes = (array)$class; |
|
| 259 | 259 | |
| 260 | - if( wpinv_is_checkout() ) { |
|
| 261 | - $classes[] = 'wpinv-checkout'; |
|
| 262 | - $classes[] = 'wpinv-page'; |
|
| 263 | - } |
|
| 260 | + if( wpinv_is_checkout() ) { |
|
| 261 | + $classes[] = 'wpinv-checkout'; |
|
| 262 | + $classes[] = 'wpinv-page'; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - if( wpinv_is_success_page() ) { |
|
| 266 | - $classes[] = 'wpinv-success'; |
|
| 267 | - $classes[] = 'wpinv-page'; |
|
| 268 | - } |
|
| 265 | + if( wpinv_is_success_page() ) { |
|
| 266 | + $classes[] = 'wpinv-success'; |
|
| 267 | + $classes[] = 'wpinv-page'; |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 271 | - $classes[] = 'wpinv-failed-transaction'; |
|
| 272 | - $classes[] = 'wpinv-page'; |
|
| 273 | - } |
|
| 270 | + if( wpinv_is_failed_transaction_page() ) { |
|
| 271 | + $classes[] = 'wpinv-failed-transaction'; |
|
| 272 | + $classes[] = 'wpinv-page'; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - if( wpinv_is_invoice_history_page() ) { |
|
| 276 | - $classes[] = 'wpinv-history'; |
|
| 277 | - $classes[] = 'wpinv-page'; |
|
| 278 | - } |
|
| 275 | + if( wpinv_is_invoice_history_page() ) { |
|
| 276 | + $classes[] = 'wpinv-history'; |
|
| 277 | + $classes[] = 'wpinv-page'; |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | - if( wpinv_is_test_mode() ) { |
|
| 281 | - $classes[] = 'wpinv-test-mode'; |
|
| 282 | - $classes[] = 'wpinv-page'; |
|
| 283 | - } |
|
| 280 | + if( wpinv_is_test_mode() ) { |
|
| 281 | + $classes[] = 'wpinv-test-mode'; |
|
| 282 | + $classes[] = 'wpinv-page'; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - return array_unique( $classes ); |
|
| 285 | + return array_unique( $classes ); |
|
| 286 | 286 | } |
| 287 | 287 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
| 288 | 288 | |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
| 1444 | 1444 | |
| 1445 | 1445 | function wpinv_empty_cart_message() { |
| 1446 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1446 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | * @return void |
| 1454 | 1454 | */ |
| 1455 | 1455 | function wpinv_empty_checkout_cart() { |
| 1456 | - echo wpinv_empty_cart_message(); |
|
| 1456 | + echo wpinv_empty_cart_message(); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
| 1459 | 1459 | |
@@ -1589,11 +1589,11 @@ discard block |
||
| 1589 | 1589 | $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
| 1590 | 1590 | |
| 1591 | 1591 | if(!empty($gateways)){ |
| 1592 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1593 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1594 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1595 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1596 | - ?> |
|
| 1592 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1593 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1594 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1595 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1596 | + ?> |
|
| 1597 | 1597 | <div class="list-group-item"> |
| 1598 | 1598 | <div class="radio"> |
| 1599 | 1599 | <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
@@ -1606,9 +1606,9 @@ discard block |
||
| 1606 | 1606 | </div> |
| 1607 | 1607 | </div> |
| 1608 | 1608 | <?php |
| 1609 | - } |
|
| 1609 | + } |
|
| 1610 | 1610 | }else{ |
| 1611 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1611 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | 1614 | do_action( 'wpinv_payment_mode_after_gateways' ); |
@@ -976,67 +976,67 @@ |
||
| 976 | 976 | function wpinv_tool_merge_fix_taxes() { |
| 977 | 977 | global $wpdb; |
| 978 | 978 | |
| 979 | - $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
|
| 980 | - $items = $wpdb->get_results( $sql ); |
|
| 979 | + $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
|
| 980 | + $items = $wpdb->get_results( $sql ); |
|
| 981 | 981 | |
| 982 | - if ( !empty( $items ) ) { |
|
| 983 | - foreach ( $items as $item ) { |
|
| 984 | - if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
| 985 | - update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
| 986 | - } |
|
| 987 | - } |
|
| 988 | - } |
|
| 982 | + if ( !empty( $items ) ) { |
|
| 983 | + foreach ( $items as $item ) { |
|
| 984 | + if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
| 985 | + update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
| 986 | + } |
|
| 987 | + } |
|
| 988 | + } |
|
| 989 | 989 | |
| 990 | 990 | $sql = "SELECT `p`.`ID`, gdi.id AS gdp_id FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NOT NULL AND p.post_status NOT IN( 'publish', 'wpi-processing', 'wpi-renewal' ) ORDER BY `gdi`.`id` ASC"; |
| 991 | 991 | $items = $wpdb->get_results( $sql ); |
| 992 | 992 | |
| 993 | - if ( !empty( $items ) ) { |
|
| 994 | - $success = false; |
|
| 993 | + if ( !empty( $items ) ) { |
|
| 994 | + $success = false; |
|
| 995 | 995 | $message = __( 'Taxes fixed for non-paid merged GD invoices.', 'invoicing' ); |
| 996 | 996 | |
| 997 | - global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
|
| 997 | + global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
|
| 998 | 998 | |
| 999 | - foreach ( $items as $item ) { |
|
| 1000 | - $wpi_tax_rates = NULL; |
|
| 1001 | - $data = wpinv_get_invoice($item->ID); |
|
| 999 | + foreach ( $items as $item ) { |
|
| 1000 | + $wpi_tax_rates = NULL; |
|
| 1001 | + $data = wpinv_get_invoice($item->ID); |
|
| 1002 | 1002 | |
| 1003 | - if ( empty( $data ) ) { |
|
| 1004 | - continue; |
|
| 1005 | - } |
|
| 1003 | + if ( empty( $data ) ) { |
|
| 1004 | + continue; |
|
| 1005 | + } |
|
| 1006 | 1006 | |
| 1007 | - $checkout_session = wpinv_get_checkout_session(); |
|
| 1007 | + $checkout_session = wpinv_get_checkout_session(); |
|
| 1008 | 1008 | |
| 1009 | - $data_session = array(); |
|
| 1010 | - $data_session['invoice_id'] = $data->ID; |
|
| 1011 | - $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
| 1009 | + $data_session = array(); |
|
| 1010 | + $data_session['invoice_id'] = $data->ID; |
|
| 1011 | + $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
| 1012 | 1012 | |
| 1013 | - wpinv_set_checkout_session( $data_session ); |
|
| 1013 | + wpinv_set_checkout_session( $data_session ); |
|
| 1014 | 1014 | |
| 1015 | - $wpi_userID = (int)$data->get_user_id(); |
|
| 1016 | - $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
|
| 1015 | + $wpi_userID = (int)$data->get_user_id(); |
|
| 1016 | + $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
|
| 1017 | 1017 | |
| 1018 | - $data->country = sanitize_text_field( $_POST['country'] ); |
|
| 1019 | - $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 1018 | + $data->country = sanitize_text_field( $_POST['country'] ); |
|
| 1019 | + $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 1020 | 1020 | |
| 1021 | - $wpinv_ip_address_country = $data->country; |
|
| 1021 | + $wpinv_ip_address_country = $data->country; |
|
| 1022 | 1022 | |
| 1023 | - $data->recalculate_totals(true); |
|
| 1023 | + $data->recalculate_totals(true); |
|
| 1024 | 1024 | |
| 1025 | - wpinv_set_checkout_session( $checkout_session ); |
|
| 1025 | + wpinv_set_checkout_session( $checkout_session ); |
|
| 1026 | 1026 | |
| 1027 | - $update_data = array(); |
|
| 1028 | - $update_data['tax_amount'] = $data->get_tax(); |
|
| 1029 | - $update_data['paied_amount'] = $data->get_total(); |
|
| 1030 | - $update_data['invoice_id'] = $data->ID; |
|
| 1027 | + $update_data = array(); |
|
| 1028 | + $update_data['tax_amount'] = $data->get_tax(); |
|
| 1029 | + $update_data['paied_amount'] = $data->get_total(); |
|
| 1030 | + $update_data['invoice_id'] = $data->ID; |
|
| 1031 | 1031 | |
| 1032 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
| 1033 | - } |
|
| 1034 | - } else { |
|
| 1032 | + $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
| 1033 | + } |
|
| 1034 | + } else { |
|
| 1035 | 1035 | $success = false; |
| 1036 | 1036 | $message = __( 'No invoices found to fix taxes!', 'invoicing' ); |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - $response = array(); |
|
| 1039 | + $response = array(); |
|
| 1040 | 1040 | $response['success'] = $success; |
| 1041 | 1041 | $response['data']['message'] = $message; |
| 1042 | 1042 | wp_send_json( $response ); |