@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return void |
| 31 | 31 | */ |
| 32 | - public function register_tables( $force_update = false ) { |
|
| 32 | + public function register_tables($force_update = false) { |
|
| 33 | 33 | global $wpdb; |
| 34 | 34 | |
| 35 | 35 | // make WP aware of our tables |
| 36 | - foreach ( $this->tables as $table ) { |
|
| 36 | + foreach ($this->tables as $table) { |
|
| 37 | 37 | $wpdb->tables[] = $table; |
| 38 | - $name = $this->get_full_table_name( $table ); |
|
| 38 | + $name = $this->get_full_table_name($table); |
|
| 39 | 39 | $wpdb->$table = $name; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // create the tables |
| 43 | - if ( $this->schema_update_required() || $force_update ) { |
|
| 44 | - foreach ( $this->tables as $table ) { |
|
| 45 | - $this->update_table( $table ); |
|
| 43 | + if ($this->schema_update_required() || $force_update) { |
|
| 44 | + foreach ($this->tables as $table) { |
|
| 45 | + $this->update_table($table); |
|
| 46 | 46 | } |
| 47 | 47 | $this->mark_schema_update_complete(); |
| 48 | 48 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return string The CREATE TABLE statement, suitable for passing to dbDelta |
| 55 | 55 | */ |
| 56 | - abstract protected function get_table_definition( $table ); |
|
| 56 | + abstract protected function get_table_definition($table); |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Determine if the database schema is out of date |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | private function schema_update_required() { |
| 66 | 66 | $option_name = 'schema-' . static::class; |
| 67 | - $version_found_in_db = get_option( $option_name, 0 ); |
|
| 67 | + $version_found_in_db = get_option($option_name, 0); |
|
| 68 | 68 | |
| 69 | 69 | // Check for schema option stored by the Action Scheduler Custom Tables plugin in case site has migrated from that plugin with an older schema |
| 70 | - if ( 0 === $version_found_in_db ) { |
|
| 70 | + if (0 === $version_found_in_db) { |
|
| 71 | 71 | |
| 72 | 72 | $plugin_option_name = 'schema-'; |
| 73 | 73 | |
| 74 | - switch ( static::class ) { |
|
| 74 | + switch (static::class) { |
|
| 75 | 75 | case 'ActionScheduler_StoreSchema' : |
| 76 | 76 | $plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Store_Table_Maker'; |
| 77 | 77 | break; |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | break; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $version_found_in_db = get_option( $plugin_option_name, 0 ); |
|
| 83 | + $version_found_in_db = get_option($plugin_option_name, 0); |
|
| 84 | 84 | |
| 85 | - delete_option( $plugin_option_name ); |
|
| 85 | + delete_option($plugin_option_name); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return version_compare( $version_found_in_db, $this->schema_version, '<' ); |
|
| 88 | + return version_compare($version_found_in_db, $this->schema_version, '<'); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | // work around race conditions and ensure that our option updates |
| 101 | 101 | $value_to_save = (string) $this->schema_version . '.0.' . time(); |
| 102 | 102 | |
| 103 | - update_option( $option_name, $value_to_save ); |
|
| 103 | + update_option($option_name, $value_to_save); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return void |
| 112 | 112 | */ |
| 113 | - private function update_table( $table ) { |
|
| 114 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 115 | - $definition = $this->get_table_definition( $table ); |
|
| 116 | - if ( $definition ) { |
|
| 117 | - $updated = dbDelta( $definition ); |
|
| 118 | - foreach ( $updated as $updated_table => $update_description ) { |
|
| 119 | - if ( strpos( $update_description, 'Created table' ) === 0 ) { |
|
| 120 | - do_action( 'action_scheduler/created_table', $updated_table, $table ); |
|
| 113 | + private function update_table($table) { |
|
| 114 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 115 | + $definition = $this->get_table_definition($table); |
|
| 116 | + if ($definition) { |
|
| 117 | + $updated = dbDelta($definition); |
|
| 118 | + foreach ($updated as $updated_table => $update_description) { |
|
| 119 | + if (strpos($update_description, 'Created table') === 0) { |
|
| 120 | + do_action('action_scheduler/created_table', $updated_table, $table); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string The full name of the table, including the |
| 130 | 130 | * table prefix for the current blog |
| 131 | 131 | */ |
| 132 | - protected function get_full_table_name( $table ) { |
|
| 133 | - return $GLOBALS[ 'wpdb' ]->prefix . $table; |
|
| 132 | + protected function get_full_table_name($table) { |
|
| 133 | + return $GLOBALS['wpdb']->prefix . $table; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | \ No newline at end of file |
@@ -16,24 +16,24 @@ discard block |
||
| 16 | 16 | * @param string $value A (PHP ini) byte value, either shorthand or ordinary. |
| 17 | 17 | * @return int An integer byte value. |
| 18 | 18 | */ |
| 19 | - public static function convert_hr_to_bytes( $value ) { |
|
| 20 | - if ( function_exists( 'wp_convert_hr_to_bytes' ) ) { |
|
| 21 | - return wp_convert_hr_to_bytes( $value ); |
|
| 19 | + public static function convert_hr_to_bytes($value) { |
|
| 20 | + if (function_exists('wp_convert_hr_to_bytes')) { |
|
| 21 | + return wp_convert_hr_to_bytes($value); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - $value = strtolower( trim( $value ) ); |
|
| 24 | + $value = strtolower(trim($value)); |
|
| 25 | 25 | $bytes = (int) $value; |
| 26 | 26 | |
| 27 | - if ( false !== strpos( $value, 'g' ) ) { |
|
| 27 | + if (false !== strpos($value, 'g')) { |
|
| 28 | 28 | $bytes *= GB_IN_BYTES; |
| 29 | - } elseif ( false !== strpos( $value, 'm' ) ) { |
|
| 29 | + } elseif (false !== strpos($value, 'm')) { |
|
| 30 | 30 | $bytes *= MB_IN_BYTES; |
| 31 | - } elseif ( false !== strpos( $value, 'k' ) ) { |
|
| 31 | + } elseif (false !== strpos($value, 'k')) { |
|
| 32 | 32 | $bytes *= KB_IN_BYTES; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Deal with large (float) values which run into the maximum integer size. |
| 36 | - return min( $bytes, PHP_INT_MAX ); |
|
| 36 | + return min($bytes, PHP_INT_MAX); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -46,30 +46,30 @@ discard block |
||
| 46 | 46 | * @return bool|int|string The limit that was set or false on failure. |
| 47 | 47 | */ |
| 48 | 48 | public static function raise_memory_limit() { |
| 49 | - if ( function_exists( 'wp_raise_memory_limit' ) ) { |
|
| 50 | - return wp_raise_memory_limit( 'admin' ); |
|
| 49 | + if (function_exists('wp_raise_memory_limit')) { |
|
| 50 | + return wp_raise_memory_limit('admin'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $current_limit = @ini_get( 'memory_limit' ); |
|
| 54 | - $current_limit_int = self::convert_hr_to_bytes( $current_limit ); |
|
| 53 | + $current_limit = @ini_get('memory_limit'); |
|
| 54 | + $current_limit_int = self::convert_hr_to_bytes($current_limit); |
|
| 55 | 55 | |
| 56 | 56 | if ( -1 === $current_limit_int ) { |
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $wp_max_limit = WP_MAX_MEMORY_LIMIT; |
| 61 | - $wp_max_limit_int = self::convert_hr_to_bytes( $wp_max_limit ); |
|
| 62 | - $filtered_limit = apply_filters( 'admin_memory_limit', $wp_max_limit ); |
|
| 63 | - $filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit ); |
|
| 61 | + $wp_max_limit_int = self::convert_hr_to_bytes($wp_max_limit); |
|
| 62 | + $filtered_limit = apply_filters('admin_memory_limit', $wp_max_limit); |
|
| 63 | + $filtered_limit_int = self::convert_hr_to_bytes($filtered_limit); |
|
| 64 | 64 | |
| 65 | - if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) { |
|
| 66 | - if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) { |
|
| 65 | + if ( -1 === $filtered_limit_int || ($filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int) ) { |
|
| 66 | + if (false !== @ini_set('memory_limit', $filtered_limit)) { |
|
| 67 | 67 | return $filtered_limit; |
| 68 | 68 | } else { |
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | } elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) { |
| 72 | - if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) { |
|
| 72 | + if (false !== @ini_set('memory_limit', $wp_max_limit)) { |
|
| 73 | 73 | return $wp_max_limit; |
| 74 | 74 | } else { |
| 75 | 75 | return false; |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param int The time limit in seconds. |
| 87 | 87 | */ |
| 88 | - public static function raise_time_limit( $limit = 0 ) { |
|
| 89 | - if ( $limit < ini_get( 'max_execution_time' ) ) { |
|
| 88 | + public static function raise_time_limit($limit = 0) { |
|
| 89 | + if ($limit < ini_get('max_execution_time')) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ( function_exists( 'wc_set_time_limit' ) ) { |
|
| 94 | - wc_set_time_limit( $limit ); |
|
| 95 | - } elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 96 | - @set_time_limit( $limit ); |
|
| 93 | + if (function_exists('wc_set_time_limit')) { |
|
| 94 | + wc_set_time_limit($limit); |
|
| 95 | + } elseif (function_exists('set_time_limit') && false === strpos(ini_get('disable_functions'), 'set_time_limit') && !ini_get('safe_mode')) { |
|
| 96 | + @set_time_limit($limit); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | License URI: https://github.com/deliciousbrains/wp-background-processing/commit/126d7945dd3d39f39cb6488ca08fe1fb66cb351a |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if ( ! class_exists( 'WP_Async_Request' ) ) { |
|
| 15 | +if (!class_exists('WP_Async_Request')) { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Abstract WP_Async_Request class. |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | public function __construct() { |
| 66 | 66 | $this->identifier = $this->prefix . '_' . $this->action; |
| 67 | 67 | |
| 68 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 69 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 68 | + add_action('wp_ajax_' . $this->identifier, array($this, 'maybe_handle')); |
|
| 69 | + add_action('wp_ajax_nopriv_' . $this->identifier, array($this, 'maybe_handle')); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return $this |
| 78 | 78 | */ |
| 79 | - public function data( $data ) { |
|
| 79 | + public function data($data) { |
|
| 80 | 80 | $this->data = $data; |
| 81 | 81 | |
| 82 | 82 | return $this; |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | * @return array|WP_Error |
| 89 | 89 | */ |
| 90 | 90 | public function dispatch() { |
| 91 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
| 91 | + $url = add_query_arg($this->get_query_args(), $this->get_query_url()); |
|
| 92 | 92 | $args = $this->get_post_args(); |
| 93 | 93 | |
| 94 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
| 94 | + return wp_remote_post(esc_url_raw($url), $args); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | * @return array |
| 101 | 101 | */ |
| 102 | 102 | protected function get_query_args() { |
| 103 | - if ( property_exists( $this, 'query_args' ) ) { |
|
| 103 | + if (property_exists($this, 'query_args')) { |
|
| 104 | 104 | return $this->query_args; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return array( |
| 108 | 108 | 'action' => $this->identifier, |
| 109 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
| 109 | + 'nonce' => wp_create_nonce($this->identifier), |
|
| 110 | 110 | ); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | * @return string |
| 117 | 117 | */ |
| 118 | 118 | protected function get_query_url() { |
| 119 | - if ( property_exists( $this, 'query_url' ) ) { |
|
| 119 | + if (property_exists($this, 'query_url')) { |
|
| 120 | 120 | return $this->query_url; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - return admin_url( 'admin-ajax.php' ); |
|
| 123 | + return admin_url('admin-ajax.php'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return array |
| 130 | 130 | */ |
| 131 | 131 | protected function get_post_args() { |
| 132 | - if ( property_exists( $this, 'post_args' ) ) { |
|
| 132 | + if (property_exists($this, 'post_args')) { |
|
| 133 | 133 | return $this->post_args; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | 'blocking' => false, |
| 139 | 139 | 'body' => $this->data, |
| 140 | 140 | 'cookies' => $_COOKIE, |
| 141 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
| 141 | + 'sslverify' => apply_filters('https_local_ssl_verify', false), |
|
| 142 | 142 | ); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | // Don't lock up other requests while processing |
| 152 | 152 | session_write_close(); |
| 153 | 153 | |
| 154 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 154 | + check_ajax_referer($this->identifier, 'nonce'); |
|
| 155 | 155 | |
| 156 | 156 | $this->handle(); |
| 157 | 157 | |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - for ($i = $offset; $i <= $to; $i+= $stepSize) { |
|
| 92 | + for ($i = $offset; $i <= $to; $i += $stepSize) { |
|
| 93 | 93 | if ($i == $dateValue) { |
| 94 | 94 | return true; |
| 95 | 95 | } |
@@ -240,7 +240,7 @@ |
||
| 240 | 240 | $currentTime = new DateTime($currentTime); |
| 241 | 241 | $currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0); |
| 242 | 242 | $currentDate = $currentTime->format('Y-m-d H:i'); |
| 243 | - $currentTime = (int)($currentTime->getTimestamp()); |
|
| 243 | + $currentTime = (int) ($currentTime->getTimestamp()); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime; |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | -add_action( 'wpinv_manual_cc_form', '__return_false' ); |
|
| 6 | -add_filter( 'wpinv_manual_support_subscription', '__return_true' ); |
|
| 5 | +add_action('wpinv_manual_cc_form', '__return_false'); |
|
| 6 | +add_filter('wpinv_manual_support_subscription', '__return_true'); |
|
| 7 | 7 | |
| 8 | -function wpinv_process_manual_payment( $purchase_data ) { |
|
| 9 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
| 10 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 8 | +function wpinv_process_manual_payment($purchase_data) { |
|
| 9 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
| 10 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /* |
@@ -42,45 +42,45 @@ discard block |
||
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | 44 | // Record the pending payment |
| 45 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
| 45 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
| 46 | 46 | |
| 47 | - if ( !empty( $invoice ) ) { |
|
| 48 | - wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() ); |
|
| 49 | - wpinv_update_payment_status( $invoice, 'publish' ); |
|
| 47 | + if (!empty($invoice)) { |
|
| 48 | + wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key()); |
|
| 49 | + wpinv_update_payment_status($invoice, 'publish'); |
|
| 50 | 50 | |
| 51 | 51 | // Empty the shopping cart |
| 52 | 52 | wpinv_empty_cart(); |
| 53 | 53 | |
| 54 | 54 | // (Maybe) set recurring hooks. |
| 55 | - wpinv_start_manual_subscription_profile( $purchase_data['invoice_id'] ); |
|
| 55 | + wpinv_start_manual_subscription_profile($purchase_data['invoice_id']); |
|
| 56 | 56 | |
| 57 | - do_action( 'wpinv_send_to_success_page', $invoice->ID, $payment_data ); |
|
| 57 | + do_action('wpinv_send_to_success_page', $invoice->ID, $payment_data); |
|
| 58 | 58 | |
| 59 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 59 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 60 | 60 | } else { |
| 61 | - wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice ); |
|
| 61 | + wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice); |
|
| 62 | 62 | // If errors are present, send the user back to the purchase page so they can be corrected |
| 63 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
| 63 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | -add_action( 'wpinv_gateway_manual', 'wpinv_process_manual_payment' ); |
|
| 66 | +add_action('wpinv_gateway_manual', 'wpinv_process_manual_payment'); |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Starts a manual subscription profile. |
| 70 | 70 | */ |
| 71 | -function wpinv_start_manual_subscription_profile( $invoice_id ) { |
|
| 71 | +function wpinv_start_manual_subscription_profile($invoice_id) { |
|
| 72 | 72 | |
| 73 | 73 | // Retrieve the subscription. |
| 74 | - $subscription = wpinv_get_subscription( $invoice_id ); |
|
| 75 | - if ( empty( $subscription ) ) { |
|
| 74 | + $subscription = wpinv_get_subscription($invoice_id); |
|
| 75 | + if (empty($subscription)) { |
|
| 76 | 76 | return; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // Schedule an action to run when the subscription expires. |
| 80 | 80 | $action_id = as_schedule_single_action( |
| 81 | - strtotime( $subscription->expiration ), |
|
| 81 | + strtotime($subscription->expiration), |
|
| 82 | 82 | 'wpinv_renew_manual_subscription_profile', |
| 83 | - array( $invoice_id ), |
|
| 83 | + array($invoice_id), |
|
| 84 | 84 | 'invoicing' |
| 85 | 85 | ); |
| 86 | 86 | |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | /** |
| 98 | 98 | * Renews a manual subscription profile. |
| 99 | 99 | */ |
| 100 | -function wpinv_renew_manual_subscription_profile( $invoice_id ) { |
|
| 100 | +function wpinv_renew_manual_subscription_profile($invoice_id) { |
|
| 101 | 101 | |
| 102 | 102 | // Retrieve the subscription. |
| 103 | - $subscription = wpinv_get_subscription( $invoice_id ); |
|
| 104 | - if ( empty( $subscription ) ) { |
|
| 103 | + $subscription = wpinv_get_subscription($invoice_id); |
|
| 104 | + if (empty($subscription)) { |
|
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -109,29 +109,29 @@ discard block |
||
| 109 | 109 | $max_bills = $subscription->bill_times; |
| 110 | 110 | |
| 111 | 111 | // If we have not maxed out on bill times... |
| 112 | - if ( empty( $bill_times ) || $times_billed > $max_bills ) { |
|
| 112 | + if (empty($bill_times) || $times_billed > $max_bills) { |
|
| 113 | 113 | |
| 114 | 114 | // Renew the subscription. |
| 115 | - $subscription->add_payment( array( |
|
| 115 | + $subscription->add_payment(array( |
|
| 116 | 116 | 'amount' => $subscription->recurring_amount, |
| 117 | 117 | 'transaction_id' => time(), |
| 118 | 118 | 'gateway' => 'manual' |
| 119 | - ) ); |
|
| 119 | + )); |
|
| 120 | 120 | |
| 121 | 121 | // Calculate the new expiration. |
| 122 | - $new_expiration = strtotime( "+ {$subscription->frequency} {$subscription->period}", strtotime( $subscription->expiration ) ); |
|
| 122 | + $new_expiration = strtotime("+ {$subscription->frequency} {$subscription->period}", strtotime($subscription->expiration)); |
|
| 123 | 123 | |
| 124 | 124 | // Schedule an action to run when the subscription expires. |
| 125 | 125 | $action_id = as_schedule_single_action( |
| 126 | 126 | $new_expiration, |
| 127 | 127 | 'wpinv_renew_manual_subscription_profile', |
| 128 | - array( $invoice_id ), |
|
| 128 | + array($invoice_id), |
|
| 129 | 129 | 'invoicing' |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | 132 | $subscription->update( |
| 133 | 133 | array( |
| 134 | - 'expiration' => date_i18n( 'Y-m-d H:i:s', $new_expiration ), |
|
| 134 | + 'expiration' => date_i18n('Y-m-d H:i:s', $new_expiration), |
|
| 135 | 135 | 'status' => 'active', |
| 136 | 136 | 'profile_id' => $action_id, |
| 137 | 137 | ) |
@@ -149,4 +149,4 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | } |
| 152 | -add_action( 'wpinv_renew_manual_subscription_profile', 'wpinv_renew_manual_subscription_profile' ); |
|
| 152 | +add_action('wpinv_renew_manual_subscription_profile', 'wpinv_renew_manual_subscription_profile'); |
|
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | function wpinv_subscription_init() { |
| 6 | 6 | return WPInv_Subscriptions::instance(); |
| 7 | 7 | } |
| 8 | -add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 ); |
|
| 8 | +add_action('plugins_loaded', 'wpinv_subscription_init', 100); |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * WPInv_Subscriptions Class. |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * Main WPInv_Subscriptions Instance |
| 21 | 21 | */ |
| 22 | 22 | public static function instance() { |
| 23 | - if ( ! isset( self::$instance ) ) { |
|
| 23 | + if (!isset(self::$instance)) { |
|
| 24 | 24 | self::$instance = new WPInv_Subscriptions; |
| 25 | 25 | |
| 26 | 26 | self::$instance->init(); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @since 1.0.0 |
| 36 | 36 | */ |
| 37 | - private function __construct(){ |
|
| 37 | + private function __construct() { |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | private function setup_constants() { |
| 64 | 64 | |
| 65 | 65 | // Make sure CAL_GREGORIAN is defined. |
| 66 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
| 67 | - define( 'CAL_GREGORIAN', 1 ); |
|
| 66 | + if (!defined('CAL_GREGORIAN')) { |
|
| 67 | + define('CAL_GREGORIAN', 1); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | private function actions() { |
| 78 | 78 | |
| 79 | - add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 10 ); |
|
| 80 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
| 81 | - add_action( 'init', array( $this, 'wpinv_post_actions' ) ); |
|
| 82 | - add_action( 'init', array( $this, 'wpinv_get_actions' ) ); |
|
| 83 | - add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) ); |
|
| 84 | - add_action( 'wpinv_checkout_before_send_to_gateway', array( $this, 'wpinv_checkout_add_subscription' ), -999, 2 ); |
|
| 85 | - add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) ); |
|
| 79 | + add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 10); |
|
| 80 | + add_action('admin_notices', array($this, 'notices')); |
|
| 81 | + add_action('init', array($this, 'wpinv_post_actions')); |
|
| 82 | + add_action('init', array($this, 'wpinv_get_actions')); |
|
| 83 | + add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation')); |
|
| 84 | + add_action('wpinv_checkout_before_send_to_gateway', array($this, 'wpinv_checkout_add_subscription'), -999, 2); |
|
| 85 | + add_action('wpinv_subscriptions_front_notices', array($this, 'notices')); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | public function wpinv_subscriptions_list() { |
| 105 | 105 | add_submenu_page( |
| 106 | 106 | 'wpinv', |
| 107 | - __( 'Subscriptions', 'invoicing' ), |
|
| 108 | - __( 'Subscriptions', 'invoicing' ), |
|
| 107 | + __('Subscriptions', 'invoicing'), |
|
| 108 | + __('Subscriptions', 'invoicing'), |
|
| 109 | 109 | wpinv_get_capability(), |
| 110 | 110 | 'wpinv-subscriptions', |
| 111 | 111 | 'wpinv_subscriptions_page' |
@@ -114,37 +114,37 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function notices() { |
| 116 | 116 | |
| 117 | - if( empty( $_GET['wpinv-message'] ) ) { |
|
| 117 | + if (empty($_GET['wpinv-message'])) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $type = 'updated'; |
| 122 | 122 | $message = ''; |
| 123 | 123 | |
| 124 | - switch( strtolower( $_GET['wpinv-message'] ) ) { |
|
| 124 | + switch (strtolower($_GET['wpinv-message'])) { |
|
| 125 | 125 | |
| 126 | 126 | case 'updated' : |
| 127 | 127 | |
| 128 | - $message = __( 'Subscription updated successfully.', 'invoicing' ); |
|
| 128 | + $message = __('Subscription updated successfully.', 'invoicing'); |
|
| 129 | 129 | |
| 130 | 130 | break; |
| 131 | 131 | |
| 132 | 132 | case 'deleted' : |
| 133 | 133 | |
| 134 | - $message = __( 'Subscription deleted successfully.', 'invoicing' ); |
|
| 134 | + $message = __('Subscription deleted successfully.', 'invoicing'); |
|
| 135 | 135 | |
| 136 | 136 | break; |
| 137 | 137 | |
| 138 | 138 | case 'cancelled' : |
| 139 | 139 | |
| 140 | - $message = __( 'Subscription cancelled successfully.', 'invoicing' ); |
|
| 140 | + $message = __('Subscription cancelled successfully.', 'invoicing'); |
|
| 141 | 141 | |
| 142 | 142 | break; |
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( ! empty( $message ) ) { |
|
| 147 | - echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>'; |
|
| 146 | + if (!empty($message)) { |
|
| 147 | + echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * @return void |
| 158 | 158 | */ |
| 159 | 159 | function wpinv_get_actions() { |
| 160 | - if ( isset( $_GET['wpinv_action'] ) ) { |
|
| 161 | - do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET ); |
|
| 160 | + if (isset($_GET['wpinv_action'])) { |
|
| 161 | + do_action('wpinv_' . $_GET['wpinv_action'], $_GET); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * @return void |
| 171 | 171 | */ |
| 172 | 172 | function wpinv_post_actions() { |
| 173 | - if ( isset( $_POST['wpinv_action'] ) ) { |
|
| 174 | - do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST ); |
|
| 173 | + if (isset($_POST['wpinv_action'])) { |
|
| 174 | + do_action('wpinv_' . $_POST['wpinv_action'], $_POST); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
@@ -182,24 +182,24 @@ discard block |
||
| 182 | 182 | * @param int $frequency_count The frequency of the period. |
| 183 | 183 | * @return mixed|string|void |
| 184 | 184 | */ |
| 185 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) { |
|
| 185 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
| 186 | 186 | $frequency = ''; |
| 187 | 187 | //Format period details |
| 188 | - switch ( $period ) { |
|
| 188 | + switch ($period) { |
|
| 189 | 189 | case 'day' : |
| 190 | - $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
| 190 | + $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
| 191 | 191 | break; |
| 192 | 192 | case 'week' : |
| 193 | - $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
| 193 | + $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
| 194 | 194 | break; |
| 195 | 195 | case 'month' : |
| 196 | - $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
| 196 | + $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
| 197 | 197 | break; |
| 198 | 198 | case 'year' : |
| 199 | - $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
| 199 | + $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
| 200 | 200 | break; |
| 201 | 201 | default : |
| 202 | - $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count ); |
|
| 202 | + $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count); |
|
| 203 | 203 | break; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -214,50 +214,50 @@ discard block |
||
| 214 | 214 | * @since 1.0.0 |
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | - public function wpinv_process_cancellation( $data ) { |
|
| 217 | + public function wpinv_process_cancellation($data) { |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - if( empty( $data['sub_id'] ) ) { |
|
| 220 | + if (empty($data['sub_id'])) { |
|
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if( ! is_user_logged_in() ) { |
|
| 224 | + if (!is_user_logged_in()) { |
|
| 225 | 225 | return; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) { |
|
| 229 | - wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 228 | + if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) { |
|
| 229 | + wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403)); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - $data['sub_id'] = absint( $data['sub_id'] ); |
|
| 233 | - $subscription = new WPInv_Subscription( $data['sub_id'] ); |
|
| 232 | + $data['sub_id'] = absint($data['sub_id']); |
|
| 233 | + $subscription = new WPInv_Subscription($data['sub_id']); |
|
| 234 | 234 | |
| 235 | - if( ! $subscription->can_cancel() ) { |
|
| 236 | - wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 235 | + if (!$subscription->can_cancel()) { |
|
| 236 | + wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403)); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | try { |
| 240 | 240 | |
| 241 | - do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true ); |
|
| 241 | + do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true); |
|
| 242 | 242 | |
| 243 | 243 | $subscription->cancel(); |
| 244 | 244 | |
| 245 | - if( is_admin() ) { |
|
| 245 | + if (is_admin()) { |
|
| 246 | 246 | |
| 247 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) ); |
|
| 247 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id)); |
|
| 248 | 248 | exit; |
| 249 | 249 | |
| 250 | 250 | } else { |
| 251 | 251 | |
| 252 | - $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) ); |
|
| 253 | - $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription ); |
|
| 254 | - wp_safe_redirect( $redirect ); |
|
| 252 | + $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled'))); |
|
| 253 | + $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription); |
|
| 254 | + wp_safe_redirect($redirect); |
|
| 255 | 255 | exit; |
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - } catch ( Exception $e ) { |
|
| 260 | - wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) ); |
|
| 259 | + } catch (Exception $e) { |
|
| 260 | + wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403)); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | } |
@@ -270,40 +270,40 @@ discard block |
||
| 270 | 270 | * @since 1.0.0 |
| 271 | 271 | * @return void |
| 272 | 272 | */ |
| 273 | - public function wpinv_checkout_add_subscription( $invoice, $invoice_data ) { |
|
| 274 | - if ( ! ( ! empty( $invoice->ID ) && $invoice->is_recurring() ) ) { |
|
| 273 | + public function wpinv_checkout_add_subscription($invoice, $invoice_data) { |
|
| 274 | + if (!(!empty($invoice->ID) && $invoice->is_recurring())) { |
|
| 275 | 275 | return; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | // Should we create a subscription for the invoice? |
| 279 | - if ( apply_filters( 'wpinv_skip_invoice_subscription_creation', false, $invoice ) ) { |
|
| 279 | + if (apply_filters('wpinv_skip_invoice_subscription_creation', false, $invoice)) { |
|
| 280 | 280 | return; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - $item = $invoice->get_recurring( true ); |
|
| 284 | - if ( empty( $item ) ) { |
|
| 283 | + $item = $invoice->get_recurring(true); |
|
| 284 | + if (empty($item)) { |
|
| 285 | 285 | return; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $invoice_date = $invoice->get_invoice_date( false ); |
|
| 288 | + $invoice_date = $invoice->get_invoice_date(false); |
|
| 289 | 289 | $status = 'pending'; |
| 290 | 290 | |
| 291 | - $period = $item->get_recurring_period( true ); |
|
| 291 | + $period = $item->get_recurring_period(true); |
|
| 292 | 292 | $interval = $item->get_recurring_interval(); |
| 293 | - $bill_times = (int)$item->get_recurring_limit(); |
|
| 293 | + $bill_times = (int) $item->get_recurring_limit(); |
|
| 294 | 294 | $add_period = $interval . ' ' . $period; |
| 295 | 295 | $trial_period = ''; |
| 296 | 296 | |
| 297 | - if ( $invoice->is_free_trial() ) { |
|
| 297 | + if ($invoice->is_free_trial()) { |
|
| 298 | 298 | $status = 'trialling'; |
| 299 | - $trial_period = $item->get_trial_period( true ); |
|
| 299 | + $trial_period = $item->get_trial_period(true); |
|
| 300 | 300 | $free_interval = $item->get_trial_interval(); |
| 301 | 301 | $trial_period = $free_interval . ' ' . $trial_period; |
| 302 | 302 | |
| 303 | 303 | $add_period = $trial_period; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period . ' 23:59:59', strtotime( $invoice_date ) ) ); |
|
| 306 | + $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date))); |
|
| 307 | 307 | |
| 308 | 308 | $args = array( |
| 309 | 309 | 'product_id' => $item->ID, |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | 'frequency' => $interval, |
| 314 | 314 | 'period' => $period, |
| 315 | 315 | 'initial_amount' => $invoice->get_total(), |
| 316 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
| 316 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
| 317 | 317 | 'bill_times' => $bill_times, |
| 318 | 318 | 'created' => $invoice_date, |
| 319 | 319 | 'expiration' => $expiration, |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | 'transaction_id' => '', |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | - $subscription = wpinv_get_subscription( $invoice ); |
|
| 325 | + $subscription = wpinv_get_subscription($invoice); |
|
| 326 | 326 | |
| 327 | - if ( empty( $subscription ) ) { |
|
| 327 | + if (empty($subscription)) { |
|
| 328 | 328 | $subscription = new WPInv_Subscription(); |
| 329 | - $subscription->create( $args ); |
|
| 329 | + $subscription->create($args); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | return $subscription; |
@@ -7,132 +7,132 @@ 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_item_quantities_enabled() { |
| 15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
| 15 | + $ret = wpinv_get_option('item_quantities', true); |
|
| 16 | 16 | |
| 17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
| 17 | + return (bool) apply_filters('wpinv_item_quantities_enabled', $ret); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function wpinv_get_ip() { |
| 21 | 21 | $ip = '127.0.0.1'; |
| 22 | 22 | |
| 23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
| 25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
| 27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
| 23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
| 25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
| 28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
| 31 | + return apply_filters('wpinv_get_ip', $ip); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function wpinv_get_user_agent() { |
| 35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
| 35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
| 37 | 37 | } else { |
| 38 | 38 | $user_agent = ''; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
| 41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
| 44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
| 45 | 45 | $is_negative = false; |
| 46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
| 47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
| 48 | - if ( $decimals === NULL ) { |
|
| 48 | + if ($decimals === NULL) { |
|
| 49 | 49 | $decimals = wpinv_decimals(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Sanitize the amount |
| 53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
| 57 | - $amount = str_replace( '.', '', $amount ); |
|
| 53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
| 54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
| 57 | + $amount = str_replace('.', '', $amount); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
| 61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
| 61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if( $amount < 0 ) { |
|
| 65 | + if ($amount < 0) { |
|
| 66 | 66 | $is_negative = true; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
| 69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
| 70 | 70 | |
| 71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
| 72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
| 71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
| 72 | + $amount = number_format((double) $amount, absint($decimals), '.', ''); |
|
| 73 | 73 | |
| 74 | - if( $is_negative ) { |
|
| 74 | + if ($is_negative) { |
|
| 75 | 75 | $amount *= -1; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
| 78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
| 79 | 79 | } |
| 80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 81 | 81 | |
| 82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
| 83 | - if ( $decimals === NULL ) { |
|
| 82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
| 83 | + if ($decimals === NULL) { |
|
| 84 | 84 | $decimals = wpinv_decimals(); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
| 87 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
| 89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
| 92 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
| 93 | 93 | global $post; |
| 94 | 94 | |
| 95 | 95 | $invoice_statuses = array( |
| 96 | - 'wpi-pending' => __( 'Pending Payment', 'invoicing' ), |
|
| 97 | - 'publish' => __( 'Paid', 'invoicing'), |
|
| 98 | - 'wpi-processing' => __( 'Processing', 'invoicing' ), |
|
| 99 | - 'wpi-onhold' => __( 'On Hold', 'invoicing' ), |
|
| 100 | - 'wpi-refunded' => __( 'Refunded', 'invoicing' ), |
|
| 101 | - 'wpi-cancelled' => __( 'Cancelled', 'invoicing' ), |
|
| 102 | - 'wpi-failed' => __( 'Failed', 'invoicing' ), |
|
| 103 | - 'wpi-renewal' => __( 'Renewal Payment', 'invoicing' ) |
|
| 96 | + 'wpi-pending' => __('Pending Payment', 'invoicing'), |
|
| 97 | + 'publish' => __('Paid', 'invoicing'), |
|
| 98 | + 'wpi-processing' => __('Processing', 'invoicing'), |
|
| 99 | + 'wpi-onhold' => __('On Hold', 'invoicing'), |
|
| 100 | + 'wpi-refunded' => __('Refunded', 'invoicing'), |
|
| 101 | + 'wpi-cancelled' => __('Cancelled', 'invoicing'), |
|
| 102 | + 'wpi-failed' => __('Failed', 'invoicing'), |
|
| 103 | + 'wpi-renewal' => __('Renewal Payment', 'invoicing') |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | - if ( $draft ) { |
|
| 107 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
| 106 | + if ($draft) { |
|
| 107 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ( $trashed ) { |
|
| 111 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
| 110 | + if ($trashed) { |
|
| 111 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 114 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | -function wpinv_status_nicename( $status ) { |
|
| 118 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
| 119 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
| 117 | +function wpinv_status_nicename($status) { |
|
| 118 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
| 119 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
| 120 | 120 | |
| 121 | 121 | return $status; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | function wpinv_get_currency() { |
| 125 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
| 125 | + $currency = wpinv_get_option('currency', 'USD'); |
|
| 126 | 126 | |
| 127 | - return apply_filters( 'wpinv_currency', $currency ); |
|
| 127 | + return apply_filters('wpinv_currency', $currency); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -function wpinv_currency_symbol( $currency = '' ) { |
|
| 131 | - if ( empty( $currency ) ) { |
|
| 130 | +function wpinv_currency_symbol($currency = '') { |
|
| 131 | + if (empty($currency)) { |
|
| 132 | 132 | $currency = wpinv_get_currency(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
| 135 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
| 136 | 136 | 'AED' => 'د.إ', |
| 137 | 137 | 'AFN' => '؋', |
| 138 | 138 | 'ALL' => 'L', |
@@ -295,209 +295,209 @@ discard block |
||
| 295 | 295 | 'YER' => '﷼', |
| 296 | 296 | 'ZAR' => 'R', |
| 297 | 297 | 'ZMW' => 'ZK', |
| 298 | - ) ); |
|
| 298 | + )); |
|
| 299 | 299 | |
| 300 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
| 300 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
| 301 | 301 | |
| 302 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
| 302 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | function wpinv_currency_position() { |
| 306 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
| 306 | + $position = wpinv_get_option('currency_position', 'left'); |
|
| 307 | 307 | |
| 308 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
| 308 | + return apply_filters('wpinv_currency_position', $position); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | function wpinv_thousands_separator() { |
| 312 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
| 312 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
| 313 | 313 | |
| 314 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
| 314 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | function wpinv_decimal_separator() { |
| 318 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
| 318 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
| 319 | 319 | |
| 320 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
| 320 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | function wpinv_decimals() { |
| 324 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
| 324 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
| 325 | 325 | |
| 326 | - return absint( $decimals ); |
|
| 326 | + return absint($decimals); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | function wpinv_get_currencies() { |
| 330 | 330 | $currencies = array( |
| 331 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
| 332 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
| 333 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
| 334 | - 'AED' => __( 'United Arab Emirates', 'invoicing' ), |
|
| 335 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
| 336 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
| 337 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
| 338 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
| 339 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
| 340 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
| 341 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
| 342 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
| 343 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
| 344 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
| 345 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
| 346 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
| 347 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
| 348 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
| 349 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
| 350 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
| 351 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
| 352 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
| 353 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
| 354 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
| 355 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
| 356 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
| 357 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
| 358 | - 'BYN' => __( 'Belarusian Ruble', 'invoicing' ), |
|
| 359 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
| 360 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
| 361 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
| 362 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
| 363 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
| 364 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
| 365 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
| 366 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
| 367 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
| 368 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
| 369 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
| 370 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
| 371 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
| 372 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
| 373 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
| 374 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
| 375 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
| 376 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
| 377 | - 'ETB' => __( 'Ethiopian Irr', 'invoicing' ), |
|
| 378 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
| 379 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
| 380 | - 'GEL' => __( 'Georgian Lari', 'invoicing' ), |
|
| 381 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
| 382 | - 'GHS' => __( 'Ghana Cedi', 'invoicing' ), |
|
| 383 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
| 384 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
| 385 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
| 386 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
| 387 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
| 388 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
| 389 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
| 390 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
| 391 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
| 392 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
| 393 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
| 394 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
| 395 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
| 396 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
| 397 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
| 398 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
| 399 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
| 400 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
| 401 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
| 402 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
| 403 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
| 404 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
| 405 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
| 406 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
| 407 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
| 408 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
| 409 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
| 410 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
| 411 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
| 412 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
| 413 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
| 414 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
| 415 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
| 416 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
| 417 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
| 418 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
| 419 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
| 420 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
| 421 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
| 422 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
| 423 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
| 424 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
| 425 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
| 426 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
| 427 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
| 428 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
| 429 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
| 430 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
| 431 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
| 432 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
| 433 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
| 434 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
| 435 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
| 436 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
| 437 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
| 438 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
| 439 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
| 440 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
| 441 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
| 442 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
| 443 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
| 444 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
| 445 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
| 446 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
| 447 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
| 448 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
| 449 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
| 450 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
| 451 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
| 452 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
| 453 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
| 454 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
| 455 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
| 456 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
| 457 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
| 458 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
| 459 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
| 460 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
| 461 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
| 462 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
| 463 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
| 464 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
| 465 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
| 466 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
| 467 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
| 468 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
| 469 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
| 470 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
| 471 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
| 472 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
| 473 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
| 474 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
| 475 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
| 476 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
| 477 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
| 478 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
| 479 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
| 480 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
| 481 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
| 482 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
| 483 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
| 484 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
| 485 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
| 486 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
| 487 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
| 488 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
| 489 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
| 490 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
| 491 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
| 331 | + 'USD' => __('US Dollar', 'invoicing'), |
|
| 332 | + 'EUR' => __('Euro', 'invoicing'), |
|
| 333 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
| 334 | + 'AED' => __('United Arab Emirates', 'invoicing'), |
|
| 335 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
| 336 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
| 337 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
| 338 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
| 339 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
| 340 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
| 341 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
| 342 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
| 343 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
| 344 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
| 345 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
| 346 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
| 347 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
| 348 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
| 349 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
| 350 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
| 351 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
| 352 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
| 353 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
| 354 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
| 355 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
| 356 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
| 357 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
| 358 | + 'BYN' => __('Belarusian Ruble', 'invoicing'), |
|
| 359 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
| 360 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
| 361 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
| 362 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
| 363 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
| 364 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
| 365 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
| 366 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
| 367 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
| 368 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
| 369 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
| 370 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
| 371 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
| 372 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
| 373 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
| 374 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
| 375 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
| 376 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
| 377 | + 'ETB' => __('Ethiopian Irr', 'invoicing'), |
|
| 378 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
| 379 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
| 380 | + 'GEL' => __('Georgian Lari', 'invoicing'), |
|
| 381 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
| 382 | + 'GHS' => __('Ghana Cedi', 'invoicing'), |
|
| 383 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
| 384 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
| 385 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
| 386 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
| 387 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
| 388 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
| 389 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
| 390 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
| 391 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
| 392 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
| 393 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
| 394 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
| 395 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
| 396 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
| 397 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
| 398 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
| 399 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
| 400 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
| 401 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
| 402 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
| 403 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
| 404 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
| 405 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
| 406 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
| 407 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
| 408 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
| 409 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
| 410 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
| 411 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
| 412 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
| 413 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
| 414 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
| 415 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
| 416 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
| 417 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
| 418 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
| 419 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
| 420 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
| 421 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
| 422 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
| 423 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
| 424 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
| 425 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
| 426 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
| 427 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
| 428 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
| 429 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
| 430 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
| 431 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
| 432 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
| 433 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
| 434 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
| 435 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
| 436 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
| 437 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
| 438 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
| 439 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
| 440 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
| 441 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
| 442 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
| 443 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
| 444 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
| 445 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
| 446 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
| 447 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
| 448 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
| 449 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
| 450 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
| 451 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
| 452 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
| 453 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
| 454 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
| 455 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
| 456 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
| 457 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
| 458 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
| 459 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
| 460 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
| 461 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
| 462 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
| 463 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
| 464 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
| 465 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
| 466 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
| 467 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
| 468 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
| 469 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
| 470 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
| 471 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
| 472 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
| 473 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
| 474 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
| 475 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
| 476 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
| 477 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
| 478 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
| 479 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
| 480 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
| 481 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
| 482 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
| 483 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
| 484 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
| 485 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
| 486 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
| 487 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
| 488 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
| 489 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
| 490 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
| 491 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | 494 | //asort( $currencies ); // this |
| 495 | 495 | |
| 496 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
| 496 | + return apply_filters('wpinv_currencies', $currencies); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
| 500 | - if( empty( $currency ) ) { |
|
| 499 | +function wpinv_price($amount = '', $currency = '') { |
|
| 500 | + if (empty($currency)) { |
|
| 501 | 501 | $currency = wpinv_get_currency(); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -505,14 +505,14 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | $negative = $amount < 0; |
| 507 | 507 | |
| 508 | - if ( $negative ) { |
|
| 509 | - $amount = substr( $amount, 1 ); |
|
| 508 | + if ($negative) { |
|
| 509 | + $amount = substr($amount, 1); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - $symbol = wpinv_currency_symbol( $currency ); |
|
| 512 | + $symbol = wpinv_currency_symbol($currency); |
|
| 513 | 513 | |
| 514 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
| 515 | - switch ( $currency ) { |
|
| 514 | + if ($position == 'left' || $position == 'left_space') { |
|
| 515 | + switch ($currency) { |
|
| 516 | 516 | case "GBP" : |
| 517 | 517 | case "BRL" : |
| 518 | 518 | case "EUR" : |
@@ -524,15 +524,15 @@ discard block |
||
| 524 | 524 | case "NZD" : |
| 525 | 525 | case "SGD" : |
| 526 | 526 | case "JPY" : |
| 527 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 527 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 528 | 528 | break; |
| 529 | 529 | default : |
| 530 | 530 | //$price = $currency . ' ' . $amount; |
| 531 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 531 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 532 | 532 | break; |
| 533 | 533 | } |
| 534 | 534 | } else { |
| 535 | - switch ( $currency ) { |
|
| 535 | + switch ($currency) { |
|
| 536 | 536 | case "GBP" : |
| 537 | 537 | case "BRL" : |
| 538 | 538 | case "EUR" : |
@@ -543,83 +543,83 @@ discard block |
||
| 543 | 543 | case "MXN" : |
| 544 | 544 | case "SGD" : |
| 545 | 545 | case "JPY" : |
| 546 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 546 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 547 | 547 | break; |
| 548 | 548 | default : |
| 549 | 549 | //$price = $amount . ' ' . $currency; |
| 550 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 550 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 551 | 551 | break; |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - if ( $negative ) { |
|
| 555 | + if ($negative) { |
|
| 556 | 556 | $price = '-' . $price; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
| 559 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
| 560 | 560 | |
| 561 | 561 | return $price; |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
| 564 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
| 565 | 565 | $thousands_sep = wpinv_thousands_separator(); |
| 566 | 566 | $decimal_sep = wpinv_decimal_separator(); |
| 567 | 567 | |
| 568 | - if ( $decimals === NULL ) { |
|
| 568 | + if ($decimals === NULL) { |
|
| 569 | 569 | $decimals = wpinv_decimals(); |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 573 | - $whole = substr( $amount, 0, $sep_found ); |
|
| 574 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
| 572 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
| 573 | + $whole = substr($amount, 0, $sep_found); |
|
| 574 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
| 575 | 575 | $amount = $whole . '.' . $part; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 579 | - $amount = str_replace( ',', '', $amount ); |
|
| 578 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 579 | + $amount = str_replace(',', '', $amount); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 583 | - $amount = str_replace( ' ', '', $amount ); |
|
| 582 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 583 | + $amount = str_replace(' ', '', $amount); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - if ( empty( $amount ) ) { |
|
| 586 | + if (empty($amount)) { |
|
| 587 | 587 | $amount = 0; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
| 591 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 590 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
| 591 | + $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 592 | 592 | |
| 593 | - if ( $calculate ) { |
|
| 594 | - if ( $thousands_sep === "," ) { |
|
| 595 | - $formatted = str_replace( ",", "", $formatted ); |
|
| 593 | + if ($calculate) { |
|
| 594 | + if ($thousands_sep === ",") { |
|
| 595 | + $formatted = str_replace(",", "", $formatted); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - if ( $decimal_sep === "," ) { |
|
| 599 | - $formatted = str_replace( ",", ".", $formatted ); |
|
| 598 | + if ($decimal_sep === ",") { |
|
| 599 | + $formatted = str_replace(",", ".", $formatted); |
|
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
| 603 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
| 604 | 604 | } |
| 605 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 605 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 606 | 606 | |
| 607 | -function wpinv_sanitize_key( $key ) { |
|
| 607 | +function wpinv_sanitize_key($key) { |
|
| 608 | 608 | $raw_key = $key; |
| 609 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
| 609 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
| 610 | 610 | |
| 611 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
| 611 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | -function wpinv_get_file_extension( $str ) { |
|
| 615 | - $parts = explode( '.', $str ); |
|
| 616 | - return end( $parts ); |
|
| 614 | +function wpinv_get_file_extension($str) { |
|
| 615 | + $parts = explode('.', $str); |
|
| 616 | + return end($parts); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | -function wpinv_string_is_image_url( $str ) { |
|
| 620 | - $ext = wpinv_get_file_extension( $str ); |
|
| 619 | +function wpinv_string_is_image_url($str) { |
|
| 620 | + $ext = wpinv_get_file_extension($str); |
|
| 621 | 621 | |
| 622 | - switch ( strtolower( $ext ) ) { |
|
| 622 | + switch (strtolower($ext)) { |
|
| 623 | 623 | case 'jpeg'; |
| 624 | 624 | case 'jpg'; |
| 625 | 625 | $return = true; |
@@ -635,32 +635,32 @@ discard block |
||
| 635 | 635 | break; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
| 638 | + return (bool) apply_filters('wpinv_string_is_image', $return, $str); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
| 642 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
| 641 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
| 642 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
| 643 | 643 | |
| 644 | - if ( true === $should_log ) { |
|
| 644 | + if (true === $should_log) { |
|
| 645 | 645 | $label = ''; |
| 646 | - if ( $file && $file !== '' ) { |
|
| 647 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
| 646 | + if ($file && $file !== '') { |
|
| 647 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - if ( $title && $title !== '' ) { |
|
| 650 | + if ($title && $title !== '') { |
|
| 651 | 651 | $label = $label !== '' ? $label . ' ' : ''; |
| 652 | 652 | $label .= $title . ' '; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
| 655 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
| 656 | 656 | |
| 657 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
| 658 | - error_log( $label . print_r( $log, true ) ); |
|
| 657 | + if (is_array($log) || is_object($log)) { |
|
| 658 | + error_log($label . print_r($log, true)); |
|
| 659 | 659 | } else { |
| 660 | - error_log( $label . $log ); |
|
| 660 | + error_log($label . $log); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - if ( $exit ) { |
|
| 663 | + if ($exit) { |
|
| 664 | 664 | exit; |
| 665 | 665 | } |
| 666 | 666 | } |
@@ -668,71 +668,71 @@ discard block |
||
| 668 | 668 | |
| 669 | 669 | function wpinv_is_ajax_disabled() { |
| 670 | 670 | $retval = false; |
| 671 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
| 671 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
| 674 | +function wpinv_get_current_page_url($nocache = false) { |
|
| 675 | 675 | global $wp; |
| 676 | 676 | |
| 677 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 678 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 677 | + if (get_option('permalink_structure')) { |
|
| 678 | + $base = trailingslashit(home_url($wp->request)); |
|
| 679 | 679 | } else { |
| 680 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 681 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 680 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 681 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | $scheme = is_ssl() ? 'https' : 'http'; |
| 685 | - $uri = set_url_scheme( $base, $scheme ); |
|
| 685 | + $uri = set_url_scheme($base, $scheme); |
|
| 686 | 686 | |
| 687 | - if ( is_front_page() ) { |
|
| 688 | - $uri = home_url( '/' ); |
|
| 689 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
| 687 | + if (is_front_page()) { |
|
| 688 | + $uri = home_url('/'); |
|
| 689 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
| 690 | 690 | $uri = wpinv_get_checkout_uri(); |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
| 693 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
| 694 | 694 | |
| 695 | - if ( $nocache ) { |
|
| 696 | - $uri = wpinv_add_cache_busting( $uri ); |
|
| 695 | + if ($nocache) { |
|
| 696 | + $uri = wpinv_add_cache_busting($uri); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | return $uri; |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | function wpinv_get_php_arg_separator_output() { |
| 703 | - return ini_get( 'arg_separator.output' ); |
|
| 703 | + return ini_get('arg_separator.output'); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | -function wpinv_rgb_from_hex( $color ) { |
|
| 707 | - $color = str_replace( '#', '', $color ); |
|
| 706 | +function wpinv_rgb_from_hex($color) { |
|
| 707 | + $color = str_replace('#', '', $color); |
|
| 708 | 708 | |
| 709 | 709 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
| 710 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
| 711 | - if ( empty( $color ) ) { |
|
| 710 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
| 711 | + if (empty($color)) { |
|
| 712 | 712 | return NULL; |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | - $color = str_split( $color ); |
|
| 715 | + $color = str_split($color); |
|
| 716 | 716 | |
| 717 | 717 | $rgb = array(); |
| 718 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
| 719 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
| 720 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
| 718 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
| 719 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
| 720 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
| 721 | 721 | |
| 722 | 722 | return $rgb; |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
| 726 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 725 | +function wpinv_hex_darker($color, $factor = 30) { |
|
| 726 | + $base = wpinv_rgb_from_hex($color); |
|
| 727 | 727 | $color = '#'; |
| 728 | 728 | |
| 729 | - foreach ( $base as $k => $v ) { |
|
| 729 | + foreach ($base as $k => $v) { |
|
| 730 | 730 | $amount = $v / 100; |
| 731 | - $amount = round( $amount * $factor ); |
|
| 731 | + $amount = round($amount * $factor); |
|
| 732 | 732 | $new_decimal = $v - $amount; |
| 733 | 733 | |
| 734 | - $new_hex_component = dechex( $new_decimal ); |
|
| 735 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 734 | + $new_hex_component = dechex($new_decimal); |
|
| 735 | + if (strlen($new_hex_component) < 2) { |
|
| 736 | 736 | $new_hex_component = "0" . $new_hex_component; |
| 737 | 737 | } |
| 738 | 738 | $color .= $new_hex_component; |
@@ -741,18 +741,18 @@ discard block |
||
| 741 | 741 | return $color; |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
| 745 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 744 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
| 745 | + $base = wpinv_rgb_from_hex($color); |
|
| 746 | 746 | $color = '#'; |
| 747 | 747 | |
| 748 | - foreach ( $base as $k => $v ) { |
|
| 748 | + foreach ($base as $k => $v) { |
|
| 749 | 749 | $amount = 255 - $v; |
| 750 | 750 | $amount = $amount / 100; |
| 751 | - $amount = round( $amount * $factor ); |
|
| 751 | + $amount = round($amount * $factor); |
|
| 752 | 752 | $new_decimal = $v + $amount; |
| 753 | 753 | |
| 754 | - $new_hex_component = dechex( $new_decimal ); |
|
| 755 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 754 | + $new_hex_component = dechex($new_decimal); |
|
| 755 | + if (strlen($new_hex_component) < 2) { |
|
| 756 | 756 | $new_hex_component = "0" . $new_hex_component; |
| 757 | 757 | } |
| 758 | 758 | $color .= $new_hex_component; |
@@ -761,22 +761,22 @@ discard block |
||
| 761 | 761 | return $color; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
| 765 | - $hex = str_replace( '#', '', $color ); |
|
| 764 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
| 765 | + $hex = str_replace('#', '', $color); |
|
| 766 | 766 | |
| 767 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 768 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 769 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 767 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
| 768 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
| 769 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
| 770 | 770 | |
| 771 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
| 771 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
| 772 | 772 | |
| 773 | 773 | return $brightness > 155 ? $dark : $light; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | -function wpinv_format_hex( $hex ) { |
|
| 777 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
| 776 | +function wpinv_format_hex($hex) { |
|
| 777 | + $hex = trim(str_replace('#', '', $hex)); |
|
| 778 | 778 | |
| 779 | - if ( strlen( $hex ) == 3 ) { |
|
| 779 | + if (strlen($hex) == 3) { |
|
| 780 | 780 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
| 781 | 781 | } |
| 782 | 782 | |
@@ -796,12 +796,12 @@ discard block |
||
| 796 | 796 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 797 | 797 | * @return string |
| 798 | 798 | */ |
| 799 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 800 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 801 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 799 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 800 | + if (function_exists('mb_strimwidth')) { |
|
| 801 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 804 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
@@ -813,28 +813,28 @@ discard block |
||
| 813 | 813 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 814 | 814 | * @return int Returns the number of characters in string. |
| 815 | 815 | */ |
| 816 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 817 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 818 | - return mb_strlen( $str, $encoding ); |
|
| 816 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 817 | + if (function_exists('mb_strlen')) { |
|
| 818 | + return mb_strlen($str, $encoding); |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - return strlen( $str ); |
|
| 821 | + return strlen($str); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
| 825 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
| 826 | - return mb_strtolower( $str, $encoding ); |
|
| 824 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
| 825 | + if (function_exists('mb_strtolower')) { |
|
| 826 | + return mb_strtolower($str, $encoding); |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - return strtolower( $str ); |
|
| 829 | + return strtolower($str); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
| 833 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
| 834 | - return mb_strtoupper( $str, $encoding ); |
|
| 832 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
| 833 | + if (function_exists('mb_strtoupper')) { |
|
| 834 | + return mb_strtoupper($str, $encoding); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - return strtoupper( $str ); |
|
| 837 | + return strtoupper($str); |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | /** |
@@ -848,12 +848,12 @@ discard block |
||
| 848 | 848 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 849 | 849 | * @return int Returns the position of the first occurrence of search in the string. |
| 850 | 850 | */ |
| 851 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 852 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 853 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 851 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 852 | + if (function_exists('mb_strpos')) { |
|
| 853 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - return strpos( $str, $find, $offset ); |
|
| 856 | + return strpos($str, $find, $offset); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
@@ -867,12 +867,12 @@ discard block |
||
| 867 | 867 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 868 | 868 | * @return int Returns the position of the last occurrence of search. |
| 869 | 869 | */ |
| 870 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 871 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 872 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 870 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 871 | + if (function_exists('mb_strrpos')) { |
|
| 872 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | - return strrpos( $str, $find, $offset ); |
|
| 875 | + return strrpos($str, $find, $offset); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | /** |
@@ -887,16 +887,16 @@ discard block |
||
| 887 | 887 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 888 | 888 | * @return string |
| 889 | 889 | */ |
| 890 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 891 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 892 | - if ( $length === null ) { |
|
| 893 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 890 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 891 | + if (function_exists('mb_substr')) { |
|
| 892 | + if ($length === null) { |
|
| 893 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 894 | 894 | } else { |
| 895 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 895 | + return mb_substr($str, $start, $length, $encoding); |
|
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - return substr( $str, $start, $length ); |
|
| 899 | + return substr($str, $start, $length); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -908,48 +908,48 @@ discard block |
||
| 908 | 908 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 909 | 909 | * @return string The width of string. |
| 910 | 910 | */ |
| 911 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 912 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 913 | - return mb_strwidth( $str, $encoding ); |
|
| 911 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 912 | + if (function_exists('mb_strwidth')) { |
|
| 913 | + return mb_strwidth($str, $encoding); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
| 916 | + return wpinv_utf8_strlen($str, $encoding); |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 920 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 921 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 919 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 920 | + if (function_exists('mb_strlen')) { |
|
| 921 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 922 | 922 | $str_end = ""; |
| 923 | 923 | |
| 924 | - if ( $lower_str_end ) { |
|
| 925 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 924 | + if ($lower_str_end) { |
|
| 925 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 926 | 926 | } else { |
| 927 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 927 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | return $first_letter . $str_end; |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | - return ucfirst( $str ); |
|
| 933 | + return ucfirst($str); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
| 937 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
| 938 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
| 936 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
| 937 | + if (function_exists('mb_convert_case')) { |
|
| 938 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
| 939 | 939 | } |
| 940 | 940 | |
| 941 | - return ucwords( $str ); |
|
| 941 | + return ucwords($str); |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | -function wpinv_period_in_days( $period, $unit ) { |
|
| 945 | - $period = absint( $period ); |
|
| 944 | +function wpinv_period_in_days($period, $unit) { |
|
| 945 | + $period = absint($period); |
|
| 946 | 946 | |
| 947 | - if ( $period > 0 ) { |
|
| 948 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
| 947 | + if ($period > 0) { |
|
| 948 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
| 949 | 949 | $period = $period * 7; |
| 950 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
| 950 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
| 951 | 951 | $period = $period * 30; |
| 952 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
| 952 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
| 953 | 953 | $period = $period * 365; |
| 954 | 954 | } |
| 955 | 955 | } |
@@ -957,14 +957,14 @@ discard block |
||
| 957 | 957 | return $period; |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
| 961 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
| 962 | - return cal_days_in_month( $calendar, $month, $year ); |
|
| 960 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
| 961 | + if (function_exists('cal_days_in_month')) { |
|
| 962 | + return cal_days_in_month($calendar, $month, $year); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | // Fallback in case the calendar extension is not loaded in PHP |
| 966 | 966 | // Only supports Gregorian calendar |
| 967 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 967 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -975,11 +975,11 @@ discard block |
||
| 975 | 975 | * |
| 976 | 976 | * @return string |
| 977 | 977 | */ |
| 978 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
| 979 | - if ( $allow_html ) { |
|
| 980 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
| 978 | +function wpi_help_tip($tip, $allow_html = false) { |
|
| 979 | + if ($allow_html) { |
|
| 980 | + $tip = wpi_sanitize_tooltip($tip); |
|
| 981 | 981 | } else { |
| 982 | - $tip = esc_attr( $tip ); |
|
| 982 | + $tip = esc_attr($tip); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -993,8 +993,8 @@ discard block |
||
| 993 | 993 | * @param string $var |
| 994 | 994 | * @return string |
| 995 | 995 | */ |
| 996 | -function wpi_sanitize_tooltip( $var ) { |
|
| 997 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 996 | +function wpi_sanitize_tooltip($var) { |
|
| 997 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 998 | 998 | 'br' => array(), |
| 999 | 999 | 'em' => array(), |
| 1000 | 1000 | 'strong' => array(), |
@@ -1004,7 +1004,7 @@ discard block |
||
| 1004 | 1004 | 'li' => array(), |
| 1005 | 1005 | 'ol' => array(), |
| 1006 | 1006 | 'p' => array(), |
| 1007 | - ) ) ); |
|
| 1007 | + ))); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | /** |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | */ |
| 1015 | 1015 | function wpinv_get_screen_ids() { |
| 1016 | 1016 | |
| 1017 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
| 1017 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
| 1018 | 1018 | |
| 1019 | 1019 | $screen_ids = array( |
| 1020 | 1020 | 'toplevel_page_' . $screen_id, |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | 'invoicing_page_wpi-addons', |
| 1033 | 1033 | ); |
| 1034 | 1034 | |
| 1035 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
| 1035 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | /** |
@@ -1043,9 +1043,9 @@ discard block |
||
| 1043 | 1043 | * @param array|string $list List of values. |
| 1044 | 1044 | * @return array Sanitized array of values. |
| 1045 | 1045 | */ |
| 1046 | -function wpinv_parse_list( $list ) { |
|
| 1047 | - if ( ! is_array( $list ) ) { |
|
| 1048 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 1046 | +function wpinv_parse_list($list) { |
|
| 1047 | + if (!is_array($list)) { |
|
| 1048 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | return $list; |
@@ -1059,16 +1059,16 @@ discard block |
||
| 1059 | 1059 | * @param string $key Type of data to fetch. |
| 1060 | 1060 | * @return mixed Fetched data. |
| 1061 | 1061 | */ |
| 1062 | -function wpinv_get_data( $key ) { |
|
| 1062 | +function wpinv_get_data($key) { |
|
| 1063 | 1063 | |
| 1064 | 1064 | // Try fetching it from the cache. |
| 1065 | - $data = wp_cache_get( "wpinv-$key", 'wpinv' ); |
|
| 1066 | - if( $data ) { |
|
| 1065 | + $data = wp_cache_get("wpinv-$key", 'wpinv'); |
|
| 1066 | + if ($data) { |
|
| 1067 | 1067 | return $data; |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
| 1071 | - wp_cache_set( "wpinv-$key", $data, 'wpinv' ); |
|
| 1070 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
| 1071 | + wp_cache_set("wpinv-$key", $data, 'wpinv'); |
|
| 1072 | 1072 | |
| 1073 | 1073 | return $data; |
| 1074 | 1074 | } |
@@ -1082,10 +1082,10 @@ discard block |
||
| 1082 | 1082 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 1083 | 1083 | * @return mixed Fetched data. |
| 1084 | 1084 | */ |
| 1085 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
| 1085 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
| 1086 | 1086 | |
| 1087 | - if ( ! empty( $options ) && $first_empty ) { |
|
| 1088 | - return array_merge( array( '' => '' ), $options ); |
|
| 1087 | + if (!empty($options) && $first_empty) { |
|
| 1088 | + return array_merge(array('' => ''), $options); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | return $options; |
| 1091 | 1091 | |
@@ -1097,19 +1097,19 @@ discard block |
||
| 1097 | 1097 | * @param mixed $var Data to sanitize. |
| 1098 | 1098 | * @return string|array |
| 1099 | 1099 | */ |
| 1100 | -function wpinv_clean( $var ) { |
|
| 1100 | +function wpinv_clean($var) { |
|
| 1101 | 1101 | |
| 1102 | - if ( is_array( $var ) ) { |
|
| 1103 | - return array_map( 'wpinv_clean', $var ); |
|
| 1102 | + if (is_array($var)) { |
|
| 1103 | + return array_map('wpinv_clean', $var); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - if ( is_object( $var ) ) { |
|
| 1107 | - $object_vars = get_object_vars( $var ); |
|
| 1108 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 1109 | - $var->$property_name = wpinv_clean( $property_value ); |
|
| 1106 | + if (is_object($var)) { |
|
| 1107 | + $object_vars = get_object_vars($var); |
|
| 1108 | + foreach ($object_vars as $property_name => $property_value) { |
|
| 1109 | + $var->$property_name = wpinv_clean($property_value); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | return $var; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
| 1114 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
| 1115 | 1115 | } |
| 1116 | 1116 | \ No newline at end of file |
@@ -7,38 +7,38 @@ 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 | -add_action( 'init', 'wpinv_register_post_types', 1 ); |
|
| 14 | +add_action('init', 'wpinv_register_post_types', 1); |
|
| 15 | 15 | function wpinv_register_post_types() { |
| 16 | 16 | |
| 17 | 17 | $labels = array( |
| 18 | - 'name' => _x( 'Invoices', 'post type general name', 'invoicing' ), |
|
| 19 | - 'singular_name' => _x( 'Invoice', 'post type singular name', 'invoicing' ), |
|
| 20 | - 'menu_name' => _x( 'Invoices', 'admin menu', 'invoicing' ), |
|
| 21 | - 'name_admin_bar' => _x( 'Invoice', 'add new on admin bar', 'invoicing' ), |
|
| 22 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
| 23 | - 'add_new_item' => __( 'Add New Invoice', 'invoicing' ), |
|
| 24 | - 'new_item' => __( 'New Invoice', 'invoicing' ), |
|
| 25 | - 'edit_item' => __( 'Edit Invoice', 'invoicing' ), |
|
| 26 | - 'view_item' => __( 'View Invoice', 'invoicing' ), |
|
| 27 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
| 28 | - 'search_items' => __( 'Search Invoices', 'invoicing' ), |
|
| 29 | - 'parent_item_colon' => __( 'Parent Invoices:', 'invoicing' ), |
|
| 30 | - 'not_found' => __( 'No invoices found.', 'invoicing' ), |
|
| 31 | - 'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' ) |
|
| 18 | + 'name' => _x('Invoices', 'post type general name', 'invoicing'), |
|
| 19 | + 'singular_name' => _x('Invoice', 'post type singular name', 'invoicing'), |
|
| 20 | + 'menu_name' => _x('Invoices', 'admin menu', 'invoicing'), |
|
| 21 | + 'name_admin_bar' => _x('Invoice', 'add new on admin bar', 'invoicing'), |
|
| 22 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
| 23 | + 'add_new_item' => __('Add New Invoice', 'invoicing'), |
|
| 24 | + 'new_item' => __('New Invoice', 'invoicing'), |
|
| 25 | + 'edit_item' => __('Edit Invoice', 'invoicing'), |
|
| 26 | + 'view_item' => __('View Invoice', 'invoicing'), |
|
| 27 | + 'all_items' => __('Invoices', 'invoicing'), |
|
| 28 | + 'search_items' => __('Search Invoices', 'invoicing'), |
|
| 29 | + 'parent_item_colon' => __('Parent Invoices:', 'invoicing'), |
|
| 30 | + 'not_found' => __('No invoices found.', 'invoicing'), |
|
| 31 | + 'not_found_in_trash' => __('No invoices found in trash.', 'invoicing') |
|
| 32 | 32 | ); |
| 33 | - $labels = apply_filters( 'wpinv_labels', $labels ); |
|
| 33 | + $labels = apply_filters('wpinv_labels', $labels); |
|
| 34 | 34 | |
| 35 | 35 | $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico'; |
| 36 | - $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon ); |
|
| 36 | + $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon); |
|
| 37 | 37 | |
| 38 | 38 | $cap_type = 'wpi_invoice'; |
| 39 | 39 | $args = array( |
| 40 | 40 | 'labels' => $labels, |
| 41 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
| 41 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
| 42 | 42 | 'public' => true, |
| 43 | 43 | 'can_export' => true, |
| 44 | 44 | '_builtin' => false, |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | 'has_archive' => false, |
| 72 | 72 | 'hierarchical' => false, |
| 73 | 73 | 'menu_position' => null, |
| 74 | - 'supports' => array( 'title', 'author' ), |
|
| 74 | + 'supports' => array('title', 'author'), |
|
| 75 | 75 | 'menu_icon' => 'dashicons-media-spreadsheet', |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $args = apply_filters( 'wpinv_register_post_type_invoice', $args ); |
|
| 78 | + $args = apply_filters('wpinv_register_post_type_invoice', $args); |
|
| 79 | 79 | |
| 80 | - register_post_type( 'wpi_invoice', $args ); |
|
| 80 | + register_post_type('wpi_invoice', $args); |
|
| 81 | 81 | |
| 82 | 82 | $cap_type = 'wpi_payment_form'; |
| 83 | 83 | register_post_type( |
@@ -86,22 +86,22 @@ discard block |
||
| 86 | 86 | 'wpinv_register_post_type_payment_form', |
| 87 | 87 | array( |
| 88 | 88 | 'labels' => array( |
| 89 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
| 90 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
| 91 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
| 92 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
| 93 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
| 94 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
| 95 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
| 96 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
| 97 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
| 98 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
| 99 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
| 100 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
| 101 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
| 102 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
| 89 | + 'name' => _x('Payment Forms', 'post type general name', 'invoicing'), |
|
| 90 | + 'singular_name' => _x('Payment Form', 'post type singular name', 'invoicing'), |
|
| 91 | + 'menu_name' => _x('Payment Forms', 'admin menu', 'invoicing'), |
|
| 92 | + 'name_admin_bar' => _x('Payment Form', 'add new on admin bar', 'invoicing'), |
|
| 93 | + 'add_new' => _x('Add New', 'Payment Form', 'invoicing'), |
|
| 94 | + 'add_new_item' => __('Add New Payment Form', 'invoicing'), |
|
| 95 | + 'new_item' => __('New Payment Form', 'invoicing'), |
|
| 96 | + 'edit_item' => __('Edit Payment Form', 'invoicing'), |
|
| 97 | + 'view_item' => __('View Payment Form', 'invoicing'), |
|
| 98 | + 'all_items' => __('Payment Forms', 'invoicing'), |
|
| 99 | + 'search_items' => __('Search Payment Forms', 'invoicing'), |
|
| 100 | + 'parent_item_colon' => __('Parent Payment Forms:', 'invoicing'), |
|
| 101 | + 'not_found' => __('No payment forms found.', 'invoicing'), |
|
| 102 | + 'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing') |
|
| 103 | 103 | ), |
| 104 | - 'description' => __( 'Stores payment forms.', 'invoicing' ), |
|
| 104 | + 'description' => __('Stores payment forms.', 'invoicing'), |
|
| 105 | 105 | 'public' => false, |
| 106 | 106 | 'show_ui' => true, |
| 107 | 107 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true, |
@@ -112,40 +112,40 @@ discard block |
||
| 112 | 112 | 'has_archive' => false, |
| 113 | 113 | 'hierarchical' => false, |
| 114 | 114 | 'menu_position' => null, |
| 115 | - 'supports' => array( 'title' ), |
|
| 115 | + 'supports' => array('title'), |
|
| 116 | 116 | 'menu_icon' => 'dashicons-media-form', |
| 117 | 117 | ) |
| 118 | 118 | ) |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | 121 | $items_labels = array( |
| 122 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
| 123 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
| 124 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
| 125 | - 'add_new' => _x( 'Add New', 'wpi_item', 'invoicing' ), |
|
| 126 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
| 127 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
| 128 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
| 129 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
| 130 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
| 131 | - 'search_items' => __( 'Search Items', 'invoicing' ), |
|
| 122 | + 'name' => _x('Items', 'post type general name', 'invoicing'), |
|
| 123 | + 'singular_name' => _x('Item', 'post type singular name', 'invoicing'), |
|
| 124 | + 'menu_name' => _x('Items', 'admin menu', 'invoicing'), |
|
| 125 | + 'add_new' => _x('Add New', 'wpi_item', 'invoicing'), |
|
| 126 | + 'add_new_item' => __('Add New Item', 'invoicing'), |
|
| 127 | + 'new_item' => __('New Item', 'invoicing'), |
|
| 128 | + 'edit_item' => __('Edit Item', 'invoicing'), |
|
| 129 | + 'view_item' => __('View Item', 'invoicing'), |
|
| 130 | + 'all_items' => __('Items', 'invoicing'), |
|
| 131 | + 'search_items' => __('Search Items', 'invoicing'), |
|
| 132 | 132 | 'parent_item_colon' => '', |
| 133 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
| 134 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
| 133 | + 'not_found' => __('No items found.', 'invoicing'), |
|
| 134 | + 'not_found_in_trash' => __('No items found in trash.', 'invoicing') |
|
| 135 | 135 | ); |
| 136 | - $items_labels = apply_filters( 'wpinv_items_labels', $items_labels ); |
|
| 136 | + $items_labels = apply_filters('wpinv_items_labels', $items_labels); |
|
| 137 | 137 | |
| 138 | 138 | $cap_type = 'wpi_item'; |
| 139 | 139 | $invoice_item_args = array( |
| 140 | 140 | 'labels' => $items_labels, |
| 141 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
| 141 | + 'description' => __('This is where you can add new invoice items.', 'invoicing'), |
|
| 142 | 142 | 'public' => false, |
| 143 | 143 | 'has_archive' => false, |
| 144 | 144 | '_builtin' => false, |
| 145 | 145 | 'show_ui' => true, |
| 146 | 146 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
| 147 | 147 | 'show_in_nav_menus' => false, |
| 148 | - 'supports' => array( 'title', 'excerpt' ), |
|
| 148 | + 'supports' => array('title', 'excerpt'), |
|
| 149 | 149 | 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
| 150 | 150 | 'rewrite' => false, |
| 151 | 151 | 'query_var' => false, |
@@ -172,33 +172,33 @@ discard block |
||
| 172 | 172 | ), |
| 173 | 173 | 'can_export' => true, |
| 174 | 174 | ); |
| 175 | - $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args ); |
|
| 175 | + $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args); |
|
| 176 | 176 | |
| 177 | - register_post_type( 'wpi_item', $invoice_item_args ); |
|
| 177 | + register_post_type('wpi_item', $invoice_item_args); |
|
| 178 | 178 | |
| 179 | 179 | $labels = array( |
| 180 | - 'name' => _x( 'Discounts', 'post type general name', 'invoicing' ), |
|
| 181 | - 'singular_name' => _x( 'Discount', 'post type singular name', 'invoicing' ), |
|
| 182 | - 'menu_name' => _x( 'Discounts', 'admin menu', 'invoicing' ), |
|
| 183 | - 'name_admin_bar' => _x( 'Discount', 'add new on admin bar', 'invoicing' ), |
|
| 184 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
| 185 | - 'add_new_item' => __( 'Add New Discount', 'invoicing' ), |
|
| 186 | - 'new_item' => __( 'New Discount', 'invoicing' ), |
|
| 187 | - 'edit_item' => __( 'Edit Discount', 'invoicing' ), |
|
| 188 | - 'view_item' => __( 'View Discount', 'invoicing' ), |
|
| 189 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
| 190 | - 'search_items' => __( 'Search Discounts', 'invoicing' ), |
|
| 191 | - 'parent_item_colon' => __( 'Parent Discounts:', 'invoicing' ), |
|
| 192 | - 'not_found' => __( 'No discounts found.', 'invoicing' ), |
|
| 193 | - 'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' ) |
|
| 180 | + 'name' => _x('Discounts', 'post type general name', 'invoicing'), |
|
| 181 | + 'singular_name' => _x('Discount', 'post type singular name', 'invoicing'), |
|
| 182 | + 'menu_name' => _x('Discounts', 'admin menu', 'invoicing'), |
|
| 183 | + 'name_admin_bar' => _x('Discount', 'add new on admin bar', 'invoicing'), |
|
| 184 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
| 185 | + 'add_new_item' => __('Add New Discount', 'invoicing'), |
|
| 186 | + 'new_item' => __('New Discount', 'invoicing'), |
|
| 187 | + 'edit_item' => __('Edit Discount', 'invoicing'), |
|
| 188 | + 'view_item' => __('View Discount', 'invoicing'), |
|
| 189 | + 'all_items' => __('Discounts', 'invoicing'), |
|
| 190 | + 'search_items' => __('Search Discounts', 'invoicing'), |
|
| 191 | + 'parent_item_colon' => __('Parent Discounts:', 'invoicing'), |
|
| 192 | + 'not_found' => __('No discounts found.', 'invoicing'), |
|
| 193 | + 'not_found_in_trash' => __('No discounts found in trash.', 'invoicing') |
|
| 194 | 194 | ); |
| 195 | - $labels = apply_filters( 'wpinv_discounts_labels', $labels ); |
|
| 195 | + $labels = apply_filters('wpinv_discounts_labels', $labels); |
|
| 196 | 196 | |
| 197 | 197 | $cap_type = 'wpi_discount'; |
| 198 | 198 | |
| 199 | 199 | $args = array( |
| 200 | 200 | 'labels' => $labels, |
| 201 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
| 201 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
| 202 | 202 | 'public' => false, |
| 203 | 203 | 'can_export' => true, |
| 204 | 204 | '_builtin' => false, |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | ), |
| 230 | 230 | 'has_archive' => false, |
| 231 | 231 | 'hierarchical' => false, |
| 232 | - 'supports' => array( 'title', 'excerpt' ), |
|
| 232 | + 'supports' => array('title', 'excerpt'), |
|
| 233 | 233 | 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
| 234 | 234 | 'show_in_nav_menus' => false, |
| 235 | 235 | 'show_in_admin_bar' => true, |
@@ -237,106 +237,106 @@ discard block |
||
| 237 | 237 | 'menu_position' => null, |
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | - $args = apply_filters( 'wpinv_register_post_type_discount', $args ); |
|
| 240 | + $args = apply_filters('wpinv_register_post_type_discount', $args); |
|
| 241 | 241 | |
| 242 | - register_post_type( 'wpi_discount', $args ); |
|
| 242 | + register_post_type('wpi_discount', $args); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | function wpinv_get_default_labels() { |
| 246 | 246 | $defaults = array( |
| 247 | - 'singular' => __( 'Invoice', 'invoicing' ), |
|
| 248 | - 'plural' => __( 'Invoices', 'invoicing' ) |
|
| 247 | + 'singular' => __('Invoice', 'invoicing'), |
|
| 248 | + 'plural' => __('Invoices', 'invoicing') |
|
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - return apply_filters( 'wpinv_default_invoices_name', $defaults ); |
|
| 251 | + return apply_filters('wpinv_default_invoices_name', $defaults); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | -function wpinv_get_label_singular( $lowercase = false ) { |
|
| 254 | +function wpinv_get_label_singular($lowercase = false) { |
|
| 255 | 255 | $defaults = wpinv_get_default_labels(); |
| 256 | 256 | |
| 257 | - return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 257 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | -function wpinv_get_label_plural( $lowercase = false ) { |
|
| 260 | +function wpinv_get_label_plural($lowercase = false) { |
|
| 261 | 261 | $defaults = wpinv_get_default_labels(); |
| 262 | 262 | |
| 263 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 263 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | -function wpinv_change_default_title( $title ) { |
|
| 267 | - if ( !is_admin() ) { |
|
| 266 | +function wpinv_change_default_title($title) { |
|
| 267 | + if (!is_admin()) { |
|
| 268 | 268 | $label = wpinv_get_label_singular(); |
| 269 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
| 269 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
| 270 | 270 | return $title; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $screen = get_current_screen(); |
| 274 | 274 | |
| 275 | - if ( 'wpi_invoice' == $screen->post_type ) { |
|
| 275 | + if ('wpi_invoice' == $screen->post_type) { |
|
| 276 | 276 | $label = wpinv_get_label_singular(); |
| 277 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
| 277 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | return $title; |
| 281 | 281 | } |
| 282 | -add_filter( 'enter_title_here', 'wpinv_change_default_title' ); |
|
| 282 | +add_filter('enter_title_here', 'wpinv_change_default_title'); |
|
| 283 | 283 | |
| 284 | 284 | function wpinv_register_post_status() { |
| 285 | - register_post_status( 'wpi-pending', array( |
|
| 286 | - 'label' => _x( 'Pending', 'Invoice status', 'invoicing' ), |
|
| 285 | + register_post_status('wpi-pending', array( |
|
| 286 | + 'label' => _x('Pending', 'Invoice status', 'invoicing'), |
|
| 287 | 287 | 'public' => true, |
| 288 | 288 | 'exclude_from_search' => true, |
| 289 | 289 | 'show_in_admin_all_list' => true, |
| 290 | 290 | 'show_in_admin_status_list' => true, |
| 291 | - 'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' ) |
|
| 292 | - ) ); |
|
| 293 | - register_post_status( 'wpi-processing', array( |
|
| 294 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 291 | + 'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing') |
|
| 292 | + )); |
|
| 293 | + register_post_status('wpi-processing', array( |
|
| 294 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
| 295 | 295 | 'public' => true, |
| 296 | 296 | 'exclude_from_search' => true, |
| 297 | 297 | 'show_in_admin_all_list' => true, |
| 298 | 298 | 'show_in_admin_status_list' => true, |
| 299 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
| 300 | - ) ); |
|
| 301 | - register_post_status( 'wpi-onhold', array( |
|
| 302 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
| 299 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
| 300 | + )); |
|
| 301 | + register_post_status('wpi-onhold', array( |
|
| 302 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
| 303 | 303 | 'public' => true, |
| 304 | 304 | 'exclude_from_search' => true, |
| 305 | 305 | 'show_in_admin_all_list' => true, |
| 306 | 306 | 'show_in_admin_status_list' => true, |
| 307 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
| 308 | - ) ); |
|
| 309 | - register_post_status( 'wpi-cancelled', array( |
|
| 310 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 307 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
| 308 | + )); |
|
| 309 | + register_post_status('wpi-cancelled', array( |
|
| 310 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
| 311 | 311 | 'public' => true, |
| 312 | 312 | 'exclude_from_search' => true, |
| 313 | 313 | 'show_in_admin_all_list' => true, |
| 314 | 314 | 'show_in_admin_status_list' => true, |
| 315 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
| 316 | - ) ); |
|
| 317 | - register_post_status( 'wpi-refunded', array( |
|
| 318 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 315 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
| 316 | + )); |
|
| 317 | + register_post_status('wpi-refunded', array( |
|
| 318 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
| 319 | 319 | 'public' => true, |
| 320 | 320 | 'exclude_from_search' => true, |
| 321 | 321 | 'show_in_admin_all_list' => true, |
| 322 | 322 | 'show_in_admin_status_list' => true, |
| 323 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
| 324 | - ) ); |
|
| 325 | - register_post_status( 'wpi-failed', array( |
|
| 326 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 323 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
| 324 | + )); |
|
| 325 | + register_post_status('wpi-failed', array( |
|
| 326 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
| 327 | 327 | 'public' => true, |
| 328 | 328 | 'exclude_from_search' => true, |
| 329 | 329 | 'show_in_admin_all_list' => true, |
| 330 | 330 | 'show_in_admin_status_list' => true, |
| 331 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
| 332 | - ) ); |
|
| 333 | - register_post_status( 'wpi-renewal', array( |
|
| 334 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
| 331 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
| 332 | + )); |
|
| 333 | + register_post_status('wpi-renewal', array( |
|
| 334 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
| 335 | 335 | 'public' => true, |
| 336 | 336 | 'exclude_from_search' => true, |
| 337 | 337 | 'show_in_admin_all_list' => true, |
| 338 | 338 | 'show_in_admin_status_list' => true, |
| 339 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
| 340 | - ) ); |
|
| 339 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
| 340 | + )); |
|
| 341 | 341 | } |
| 342 | -add_action( 'init', 'wpinv_register_post_status', 10 ); |
|
| 342 | +add_action('init', 'wpinv_register_post_status', 10); |
|