@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -11,60 +11,60 @@ discard block |
||
| 11 | 11 | public function __construct() { |
| 12 | 12 | global $bp; |
| 13 | 13 | |
| 14 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
| 15 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
| 14 | + if (!defined('WPINV_BP_SLUG')) { |
|
| 15 | + define('WPINV_BP_SLUG', 'invoices'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
| 18 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
| 19 | 19 | $position = $position !== '' && $position !== false ? $position : 91; |
| 20 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
| 20 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
| 21 | 21 | $this->slug = WPINV_BP_SLUG; |
| 22 | 22 | |
| 23 | 23 | parent::start( |
| 24 | 24 | 'invoicing', |
| 25 | - _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ), |
|
| 26 | - trailingslashit( dirname( __FILE__ ) ), |
|
| 25 | + _x('Invoices', 'Invoices screen page <title>', 'invoicing'), |
|
| 26 | + trailingslashit(dirname(__FILE__)), |
|
| 27 | 27 | array( |
| 28 | 28 | 'adminbar_myaccount_order' => $this->position |
| 29 | 29 | ) |
| 30 | 30 | ); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function includes( $includes = array() ) { |
|
| 34 | - parent::includes( $includes ); |
|
| 33 | + public function includes($includes = array()) { |
|
| 34 | + parent::includes($includes); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function setup_globals( $args = array() ) { |
|
| 37 | + public function setup_globals($args = array()) { |
|
| 38 | 38 | global $bp; |
| 39 | 39 | |
| 40 | 40 | $args = array( |
| 41 | 41 | 'slug' => $this->slug, |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - parent::setup_globals( $args ); |
|
| 44 | + parent::setup_globals($args); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
| 48 | - if ( !bp_is_my_profile() ) { |
|
| 47 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
| 48 | + if (!bp_is_my_profile()) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
| 52 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $this->setup_invoice_count(); |
| 57 | 57 | |
| 58 | 58 | $user_domain = bp_loggedin_user_domain(); |
| 59 | - $invoices_link = trailingslashit( $user_domain . $this->slug ); |
|
| 60 | - $class = ( 0 === $this->count ) ? 'no-count' : 'count'; |
|
| 59 | + $invoices_link = trailingslashit($user_domain . $this->slug); |
|
| 60 | + $class = (0 === $this->count) ? 'no-count' : 'count'; |
|
| 61 | 61 | |
| 62 | 62 | $main_nav_name = sprintf( |
| 63 | - __( 'My Invoices %s', 'invoicing' ), |
|
| 63 | + __('My Invoices %s', 'invoicing'), |
|
| 64 | 64 | sprintf( |
| 65 | 65 | '<span class="%s">%s</span>', |
| 66 | - esc_attr( $class ), |
|
| 67 | - bp_core_number_format( $this->count ) |
|
| 66 | + esc_attr($class), |
|
| 67 | + bp_core_number_format($this->count) |
|
| 68 | 68 | ) |
| 69 | 69 | ); |
| 70 | 70 | |
@@ -72,54 +72,54 @@ discard block |
||
| 72 | 72 | 'name' => $main_nav_name, |
| 73 | 73 | 'slug' => $this->slug, |
| 74 | 74 | 'position' => $this->position, |
| 75 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
| 75 | + 'screen_function' => array($this, 'invoices_screen'), |
|
| 76 | 76 | 'default_subnav_slug' => 'invoices', |
| 77 | 77 | 'item_css_id' => $this->id |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | 80 | $sub_nav[] = array( |
| 81 | - 'name' => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ), |
|
| 81 | + 'name' => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'), |
|
| 82 | 82 | 'slug' => 'invoices', |
| 83 | 83 | 'parent_url' => $invoices_link, |
| 84 | 84 | 'parent_slug' => $this->slug, |
| 85 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
| 85 | + 'screen_function' => array($this, 'invoices_screen'), |
|
| 86 | 86 | 'position' => 10, |
| 87 | 87 | 'item_css_id' => 'invoices-my-invoices' |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
| 90 | + parent::setup_nav($main_nav, $sub_nav); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public function setup_title() { |
| 94 | 94 | // Adjust title. |
| 95 | - if ( (bool)bp_is_current_component( 'invoicing' ) ) { |
|
| 95 | + if ((bool)bp_is_current_component('invoicing')) { |
|
| 96 | 96 | global $bp; |
| 97 | 97 | |
| 98 | - $bp->bp_options_title = __( 'My Invoices', 'invoicing' ); |
|
| 98 | + $bp->bp_options_title = __('My Invoices', 'invoicing'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | parent::setup_title(); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public function invoices_screen() { |
| 105 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
| 105 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | global $bp; |
| 110 | 110 | |
| 111 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
| 111 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
| 112 | 112 | |
| 113 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
| 113 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
| 114 | 114 | |
| 115 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
| 115 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function invoices_content() { |
| 119 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
| 119 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
| 120 | 120 | global $invoices_template; |
| 121 | 121 | |
| 122 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
| 122 | + do_action('wpinv_bp_invoices_before_content'); |
|
| 123 | 123 | ?> |
| 124 | 124 | <div class="wpi-bp-invoices invoices invoicing" style="position:relative"> |
| 125 | 125 | <div id="pag-top" class="pagination"> |
@@ -133,58 +133,58 @@ discard block |
||
| 133 | 133 | <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0"> |
| 134 | 134 | <thead> |
| 135 | 135 | <tr> |
| 136 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
| 137 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
| 136 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
| 137 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
| 138 | 138 | <?php endforeach; ?> |
| 139 | 139 | </tr> |
| 140 | 140 | </thead> |
| 141 | 141 | <tbody> |
| 142 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
| 142 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
| 143 | 143 | ?> |
| 144 | 144 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
| 145 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
| 146 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
| 147 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
| 148 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
| 149 | - |
|
| 150 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
| 151 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
| 152 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
| 145 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
| 146 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
| 147 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
| 148 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
| 149 | + |
|
| 150 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
| 151 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
| 152 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
| 153 | 153 | </a> |
| 154 | 154 | |
| 155 | - <?php elseif ( 'invoice-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
| 156 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
| 155 | + <?php elseif ('invoice-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
| 156 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
| 157 | 157 | |
| 158 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
| 159 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
| 158 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
| 159 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
| 160 | 160 | |
| 161 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
| 162 | - <?php echo $invoice->get_total( true ); ?> |
|
| 161 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
| 162 | + <?php echo $invoice->get_total(true); ?> |
|
| 163 | 163 | |
| 164 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
| 164 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
| 165 | 165 | <?php |
| 166 | 166 | $actions = array( |
| 167 | 167 | 'pay' => array( |
| 168 | 168 | 'url' => $invoice->get_checkout_payment_url(), |
| 169 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 169 | + 'name' => __('Pay Now', 'invoicing'), |
|
| 170 | 170 | 'class' => 'btn-success' |
| 171 | 171 | ), |
| 172 | 172 | 'print' => array( |
| 173 | 173 | 'url' => $invoice->get_view_url(), |
| 174 | - 'name' => __( 'Print', 'invoicing' ), |
|
| 174 | + 'name' => __('Print', 'invoicing'), |
|
| 175 | 175 | 'class' => 'btn-primary', |
| 176 | 176 | 'attrs' => 'target="_blank"' |
| 177 | 177 | ) |
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | - if ( ! $invoice->needs_payment() ) { |
|
| 181 | - unset( $actions['pay'] ); |
|
| 180 | + if (!$invoice->needs_payment()) { |
|
| 181 | + unset($actions['pay']); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 185 | - foreach ( $actions as $key => $action ) { |
|
| 184 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
| 185 | + foreach ($actions as $key => $action) { |
|
| 186 | 186 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
| 187 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
| 187 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | ?> |
@@ -212,64 +212,64 @@ discard block |
||
| 212 | 212 | </div> |
| 213 | 213 | <?php |
| 214 | 214 | |
| 215 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
| 215 | + do_action('wpinv_bp_invoices_after_content'); |
|
| 216 | 216 | } else { |
| 217 | 217 | ?> |
| 218 | 218 | <div id="message" class="info"> |
| 219 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
| 219 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
| 220 | 220 | </div> |
| 221 | 221 | <?php |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 224 | + if (defined('DOING_AJAX')) { |
|
| 225 | 225 | exit; |
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - public function has_invoices( $args = '' ) { |
|
| 229 | + public function has_invoices($args = '') { |
|
| 230 | 230 | global $invoices_template; |
| 231 | 231 | |
| 232 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
| 232 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
| 233 | 233 | // Parse arguments. |
| 234 | - $r = bp_parse_args( $args, array( |
|
| 234 | + $r = bp_parse_args($args, array( |
|
| 235 | 235 | 'status' => 'all', |
| 236 | 236 | 'page_arg' => 'bpage', |
| 237 | 237 | 'page' => 1, |
| 238 | 238 | 'per_page' => $per_page > 0 ? $per_page : 20, |
| 239 | 239 | 'max' => false, |
| 240 | 240 | 'user_id' => bp_loggedin_user_id(), |
| 241 | - ), 'has_invoices' ); |
|
| 241 | + ), 'has_invoices'); |
|
| 242 | 242 | |
| 243 | 243 | |
| 244 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
| 244 | + if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) { |
|
| 245 | 245 | $r['per_page'] = (int)$r['max']; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | // Get the invoices. |
| 249 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
| 249 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
| 250 | 250 | |
| 251 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
| 251 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | public function setup_invoice_count() { |
| 255 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
| 256 | - $invoices = wpinv_get_invoices( $query ); |
|
| 255 | + $query = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
| 256 | + $invoices = wpinv_get_invoices($query); |
|
| 257 | 257 | |
| 258 | - $this->count = !empty( $invoices ) ? count( $invoices ) : 0; |
|
| 258 | + $this->count = !empty($invoices) ? count($invoices) : 0; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | public function pagination_count() { |
| 262 | 262 | global $invoices_template; |
| 263 | 263 | |
| 264 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
| 265 | - $from_num = bp_core_number_format( $start_num ); |
|
| 266 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
| 267 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
| 264 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
| 265 | + $from_num = bp_core_number_format($start_num); |
|
| 266 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
| 267 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
| 268 | 268 | |
| 269 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
| 270 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
| 269 | + if (1 == $invoices_template->total_invoice_count) { |
|
| 270 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
| 271 | 271 | } else { |
| 272 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
| 272 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | return $message; |
@@ -278,32 +278,32 @@ discard block |
||
| 278 | 278 | function pagination_links() { |
| 279 | 279 | global $invoices_template; |
| 280 | 280 | |
| 281 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
| 281 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - public function bp_section( $settings = array() ) { |
|
| 285 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
| 284 | + public function bp_section($settings = array()) { |
|
| 285 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
| 286 | 286 | return $settings; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - public function bp_settings( $settings = array() ) { |
|
| 289 | + public function bp_settings($settings = array()) { |
|
| 290 | 290 | $settings['wpinv_bp'] = array( |
| 291 | 291 | 'wpinv_bp_labels' => array( |
| 292 | 292 | 'id' => 'wpinv_bp_settings', |
| 293 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
| 293 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
| 294 | 294 | 'desc' => '', |
| 295 | 295 | 'type' => 'header', |
| 296 | 296 | ), |
| 297 | 297 | 'wpinv_bp_hide_menu' => array( |
| 298 | 298 | 'id' => 'wpinv_bp_hide_menu', |
| 299 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
| 300 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
| 299 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
| 300 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
| 301 | 301 | 'type' => 'checkbox', |
| 302 | 302 | ), |
| 303 | 303 | 'wpinv_menu_position' => array( |
| 304 | 304 | 'id' => 'wpinv_menu_position', |
| 305 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
| 306 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
| 305 | + 'name' => __('Menu position', 'invoicing'), |
|
| 306 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
| 307 | 307 | 'type' => 'number', |
| 308 | 308 | 'size' => 'small', |
| 309 | 309 | 'min' => '1', |
@@ -313,8 +313,8 @@ discard block |
||
| 313 | 313 | ), |
| 314 | 314 | 'wpinv_bp_per_page' => array( |
| 315 | 315 | 'id' => 'wpinv_bp_per_page', |
| 316 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
| 317 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
| 316 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
| 317 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
| 318 | 318 | 'type' => 'number', |
| 319 | 319 | 'size' => 'small', |
| 320 | 320 | 'min' => '1', |
@@ -339,25 +339,25 @@ discard block |
||
| 339 | 339 | public $pag_links = ''; |
| 340 | 340 | public $total_invoice_count = 0; |
| 341 | 341 | |
| 342 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
| 343 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
| 342 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
| 343 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
| 344 | 344 | |
| 345 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
| 346 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
| 347 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
| 345 | + $this->pag_arg = sanitize_key($page_arg); |
|
| 346 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
| 347 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
| 348 | 348 | |
| 349 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
| 350 | - if ( !empty( $status ) && $status != 'all' ) { |
|
| 349 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
| 350 | + if (!empty($status) && $status != 'all') { |
|
| 351 | 351 | $query_args['status'] = $status; |
| 352 | 352 | } |
| 353 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
| 353 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
| 354 | 354 | |
| 355 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
| 356 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
| 355 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
| 356 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
| 357 | 357 | $this->invoices['total'] = $invoices->found_posts; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
| 360 | + if (empty($max) || ($max >= (int)$this->invoices['total'])) { |
|
| 361 | 361 | $this->total_invoice_count = (int)$this->invoices['total']; |
| 362 | 362 | } else { |
| 363 | 363 | $this->total_invoice_count = (int)$max; |
@@ -365,52 +365,52 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | $this->invoices = $this->invoices['invoices']; |
| 367 | 367 | |
| 368 | - $invoice_count = count( $this->invoices ); |
|
| 368 | + $invoice_count = count($this->invoices); |
|
| 369 | 369 | |
| 370 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
| 370 | + if (empty($max) || ($max >= (int)$invoice_count)) { |
|
| 371 | 371 | $this->invoice_count = (int)$invoice_count; |
| 372 | 372 | } else { |
| 373 | 373 | $this->invoice_count = (int)$max; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
| 377 | - $this->pag_links = paginate_links( array( |
|
| 378 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
| 376 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
| 377 | + $this->pag_links = paginate_links(array( |
|
| 378 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
| 379 | 379 | 'format' => '', |
| 380 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
| 380 | + 'total' => ceil((int)$this->total_invoice_count / (int)$this->pag_num), |
|
| 381 | 381 | 'current' => (int)$this->pag_page, |
| 382 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
| 383 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
| 382 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
| 383 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
| 384 | 384 | 'mid_size' => 1, |
| 385 | 385 | 'add_args' => array(), |
| 386 | - ) ); |
|
| 386 | + )); |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | public function has_invoices() { |
| 391 | - return (bool) ! empty( $this->invoice_count ); |
|
| 391 | + return (bool)!empty($this->invoice_count); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | public function next_invoice() { |
| 395 | 395 | $this->current_invoice++; |
| 396 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
| 396 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
| 397 | 397 | |
| 398 | 398 | return $this->invoice; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | public function rewind_invoices() { |
| 402 | 402 | $this->current_invoice = -1; |
| 403 | - if ( $this->invoice_count > 0 ) { |
|
| 403 | + if ($this->invoice_count > 0) { |
|
| 404 | 404 | $this->invoice = $this->invoices[0]; |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | public function invoices() { |
| 409 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
| 409 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
| 410 | 410 | return true; |
| 411 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
| 411 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
| 412 | 412 | |
| 413 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
| 413 | + do_action('wpinv_bp_invoice_loop_end'); |
|
| 414 | 414 | |
| 415 | 415 | $this->rewind_invoices(); |
| 416 | 416 | } |
@@ -424,8 +424,8 @@ discard block |
||
| 424 | 424 | $this->in_the_loop = true; |
| 425 | 425 | $this->invoice = $this->next_invoice(); |
| 426 | 426 | |
| 427 | - if ( 0 === $this->current_invoice ) { |
|
| 428 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
| 427 | + if (0 === $this->current_invoice) { |
|
| 428 | + do_action('wpinv_bp_invoice_loop_start'); |
|
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | } |
@@ -435,9 +435,9 @@ discard block |
||
| 435 | 435 | |
| 436 | 436 | $bp->invoicing = new WPInv_BP_Component(); |
| 437 | 437 | |
| 438 | - add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
| 439 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
| 440 | - add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 ); |
|
| 441 | - add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 ); |
|
| 438 | + add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
| 439 | + add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
| 440 | + add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1); |
|
| 441 | + add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1); |
|
| 442 | 442 | } |
| 443 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
| 444 | 443 | \ No newline at end of file |
| 444 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
| 445 | 445 | \ No newline at end of file |
@@ -7,195 +7,195 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function wpinv_is_checkout() { |
| 15 | 15 | global $wp_query; |
| 16 | 16 | |
| 17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
| 18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
| 19 | - $is_checkout = is_page( wpinv_get_option( 'checkout_page' ) ); |
|
| 17 | + $is_object_set = isset($wp_query->queried_object); |
|
| 18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
| 19 | + $is_checkout = is_page(wpinv_get_option('checkout_page')); |
|
| 20 | 20 | |
| 21 | - if ( !$is_object_set ) { |
|
| 22 | - unset( $wp_query->queried_object ); |
|
| 21 | + if (!$is_object_set) { |
|
| 22 | + unset($wp_query->queried_object); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if ( !$is_object_id_set ) { |
|
| 26 | - unset( $wp_query->queried_object_id ); |
|
| 25 | + if (!$is_object_id_set) { |
|
| 26 | + unset($wp_query->queried_object_id); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
| 29 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function wpinv_can_checkout() { |
| 33 | 33 | $can_checkout = true; // Always true for now |
| 34 | 34 | |
| 35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 35 | + return (bool)apply_filters('wpinv_can_checkout', $can_checkout); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function wpinv_get_success_page_uri() { |
| 39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | - $page_id = absint( $page_id ); |
|
| 39 | + $page_id = wpinv_get_option('success_page', 0); |
|
| 40 | + $page_id = absint($page_id); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 42 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_get_history_page_uri() { |
| 46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | - $page_id = absint( $page_id ); |
|
| 46 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
| 47 | + $page_id = absint($page_id); |
|
| 48 | 48 | |
| 49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 49 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function wpinv_is_success_page() { |
| 53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 53 | + $is_success_page = wpinv_get_option('success_page', false); |
|
| 54 | + $is_success_page = isset($is_success_page) ? is_page($is_success_page) : false; |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 56 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function wpinv_is_invoice_history_page() { |
| 60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | - $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 60 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
| 61 | + $ret = $ret ? is_page($ret) : false; |
|
| 62 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -function wpinv_send_to_success_page( $args = null ) { |
|
| 65 | +function wpinv_send_to_success_page($args = null) { |
|
| 66 | 66 | $redirect = wpinv_get_success_page_uri(); |
| 67 | 67 | |
| 68 | - if ( !empty( $args ) ) { |
|
| 68 | + if (!empty($args)) { |
|
| 69 | 69 | // Check for backward compatibility |
| 70 | - if ( is_string( $args ) ) |
|
| 71 | - $args = str_replace( '?', '', $args ); |
|
| 70 | + if (is_string($args)) |
|
| 71 | + $args = str_replace('?', '', $args); |
|
| 72 | 72 | |
| 73 | - $args = wp_parse_args( $args ); |
|
| 73 | + $args = wp_parse_args($args); |
|
| 74 | 74 | |
| 75 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 75 | + $redirect = add_query_arg($args, $redirect); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 78 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 79 | 79 | |
| 80 | - $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args ); |
|
| 81 | - wp_redirect( $redirect ); |
|
| 80 | + $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args); |
|
| 81 | + wp_redirect($redirect); |
|
| 82 | 82 | exit; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
| 85 | +function wpinv_send_to_failed_page($args = null) { |
|
| 86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
| 87 | 87 | |
| 88 | - if ( !empty( $args ) ) { |
|
| 88 | + if (!empty($args)) { |
|
| 89 | 89 | // Check for backward compatibility |
| 90 | - if ( is_string( $args ) ) |
|
| 91 | - $args = str_replace( '?', '', $args ); |
|
| 90 | + if (is_string($args)) |
|
| 91 | + $args = str_replace('?', '', $args); |
|
| 92 | 92 | |
| 93 | - $args = wp_parse_args( $args ); |
|
| 93 | + $args = wp_parse_args($args); |
|
| 94 | 94 | |
| 95 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 95 | + $redirect = add_query_arg($args, $redirect); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 99 | 99 | |
| 100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
| 101 | - wp_redirect( $redirect ); |
|
| 100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
| 101 | + wp_redirect($redirect); |
|
| 102 | 102 | exit; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
| 106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 105 | +function wpinv_get_checkout_uri($args = array()) { |
|
| 106 | + $uri = wpinv_get_option('checkout_page', false); |
|
| 107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
| 108 | 108 | |
| 109 | - if ( !empty( $args ) ) { |
|
| 109 | + if (!empty($args)) { |
|
| 110 | 110 | // Check for backward compatibility |
| 111 | - if ( is_string( $args ) ) |
|
| 112 | - $args = str_replace( '?', '', $args ); |
|
| 111 | + if (is_string($args)) |
|
| 112 | + $args = str_replace('?', '', $args); |
|
| 113 | 113 | |
| 114 | - $args = wp_parse_args( $args ); |
|
| 114 | + $args = wp_parse_args($args); |
|
| 115 | 115 | |
| 116 | - $uri = add_query_arg( $args, $uri ); |
|
| 116 | + $uri = add_query_arg($args, $uri); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 120 | 120 | |
| 121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 122 | 122 | |
| 123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
| 124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -function wpinv_send_back_to_checkout( $args = array() ) { |
|
| 130 | +function wpinv_send_back_to_checkout($args = array()) { |
|
| 131 | 131 | $redirect = wpinv_get_checkout_uri(); |
| 132 | 132 | |
| 133 | - if ( ! empty( $args ) ) { |
|
| 133 | + if (!empty($args)) { |
|
| 134 | 134 | // Check for backward compatibility |
| 135 | - if ( is_string( $args ) ) |
|
| 136 | - $args = str_replace( '?', '', $args ); |
|
| 135 | + if (is_string($args)) |
|
| 136 | + $args = str_replace('?', '', $args); |
|
| 137 | 137 | |
| 138 | - $args = wp_parse_args( $args ); |
|
| 138 | + $args = wp_parse_args($args); |
|
| 139 | 139 | |
| 140 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 140 | + $redirect = add_query_arg($args, $redirect); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 143 | + wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args)); |
|
| 144 | 144 | exit; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
| 148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 149 | - $success_page = get_permalink( $success_page ); |
|
| 147 | +function wpinv_get_success_page_url($query_string = null) { |
|
| 148 | + $success_page = wpinv_get_option('success_page', 0); |
|
| 149 | + $success_page = get_permalink($success_page); |
|
| 150 | 150 | |
| 151 | - if ( $query_string ) |
|
| 151 | + if ($query_string) |
|
| 152 | 152 | $success_page .= $query_string; |
| 153 | 153 | |
| 154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 154 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
| 158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 157 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
| 158 | + $uri = wpinv_get_option('failure_page', ''); |
|
| 159 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
| 160 | 160 | |
| 161 | - if ( $extras ) |
|
| 161 | + if ($extras) |
|
| 162 | 162 | $uri .= $extras; |
| 163 | 163 | |
| 164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 164 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function wpinv_is_failed_transaction_page() { |
| 168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
| 169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 168 | + $ret = wpinv_get_option('failure_page', false); |
|
| 169 | + $ret = isset($ret) ? is_page($ret) : false; |
|
| 170 | 170 | |
| 171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 171 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | -function wpinv_transaction_query( $type = 'start' ) { |
|
| 174 | +function wpinv_transaction_query($type = 'start') { |
|
| 175 | 175 | global $wpdb; |
| 176 | 176 | |
| 177 | 177 | $wpdb->hide_errors(); |
| 178 | 178 | |
| 179 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
| 180 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
| 179 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
| 180 | + define('WPINV_USE_TRANSACTIONS', true); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
| 184 | - switch ( $type ) { |
|
| 183 | + if (WPINV_USE_TRANSACTIONS) { |
|
| 184 | + switch ($type) { |
|
| 185 | 185 | case 'commit' : |
| 186 | - $wpdb->query( 'COMMIT' ); |
|
| 186 | + $wpdb->query('COMMIT'); |
|
| 187 | 187 | break; |
| 188 | 188 | case 'rollback' : |
| 189 | - $wpdb->query( 'ROLLBACK' ); |
|
| 189 | + $wpdb->query('ROLLBACK'); |
|
| 190 | 190 | break; |
| 191 | 191 | default : |
| 192 | - $wpdb->query( 'START TRANSACTION' ); |
|
| 192 | + $wpdb->query('START TRANSACTION'); |
|
| 193 | 193 | break; |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | -function wpinv_create_invoice( $args = array(), $data = array() ) { |
|
| 198 | +function wpinv_create_invoice($args = array(), $data = array()) { |
|
| 199 | 199 | $default_args = array( |
| 200 | 200 | 'status' => '', |
| 201 | 201 | 'user_id' => null, |
@@ -205,191 +205,191 @@ discard block |
||
| 205 | 205 | 'parent' => 0 |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | - $args = wp_parse_args( $args, $default_args ); |
|
| 208 | + $args = wp_parse_args($args, $default_args); |
|
| 209 | 209 | $invoice_data = array(); |
| 210 | 210 | |
| 211 | - if ( $args['invoice_id'] > 0 ) { |
|
| 212 | - $updating = true; |
|
| 211 | + if ($args['invoice_id'] > 0) { |
|
| 212 | + $updating = true; |
|
| 213 | 213 | $invoice_data['post_type'] = 'wpi_invoice'; |
| 214 | 214 | $invoice_data['ID'] = $args['invoice_id']; |
| 215 | 215 | } else { |
| 216 | 216 | $updating = false; |
| 217 | 217 | $invoice_data['post_type'] = 'wpi_invoice'; |
| 218 | - $invoice_data['post_status'] = apply_filters( 'wpinv_default_invoice_status', 'pending' ); |
|
| 218 | + $invoice_data['post_status'] = apply_filters('wpinv_default_invoice_status', 'pending'); |
|
| 219 | 219 | $invoice_data['ping_status'] = 'closed'; |
| 220 | - $invoice_data['post_author'] = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
| 221 | - $invoice_data['post_title'] = wpinv_format_invoice_number( '0' ); |
|
| 222 | - $invoice_data['post_parent'] = absint( $args['parent'] ); |
|
| 223 | - if ( !empty( $args['created_date'] ) ) { |
|
| 220 | + $invoice_data['post_author'] = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
| 221 | + $invoice_data['post_title'] = wpinv_format_invoice_number('0'); |
|
| 222 | + $invoice_data['post_parent'] = absint($args['parent']); |
|
| 223 | + if (!empty($args['created_date'])) { |
|
| 224 | 224 | $invoice_data['post_date'] = $args['created_date']; |
| 225 | - $invoice_data['post_date_gmt'] = get_gmt_from_date( $args['created_date'] ); |
|
| 225 | + $invoice_data['post_date_gmt'] = get_gmt_from_date($args['created_date']); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( $args['status'] ) { |
|
| 230 | - if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 231 | - return new WP_Error( 'wpinv_invalid_invoice_status', __( 'Invalid invoice status', 'invoicing' ) ); |
|
| 229 | + if ($args['status']) { |
|
| 230 | + if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) { |
|
| 231 | + return new WP_Error('wpinv_invalid_invoice_status', __('Invalid invoice status', 'invoicing')); |
|
| 232 | 232 | } |
| 233 | - $invoice_data['post_status'] = $args['status']; |
|
| 233 | + $invoice_data['post_status'] = $args['status']; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( ! is_null( $args['user_note'] ) ) { |
|
| 237 | - $invoice_data['post_excerpt'] = $args['user_note']; |
|
| 236 | + if (!is_null($args['user_note'])) { |
|
| 237 | + $invoice_data['post_excerpt'] = $args['user_note']; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if ( $updating ) { |
|
| 241 | - $invoice_id = wp_update_post( $invoice_data ); |
|
| 240 | + if ($updating) { |
|
| 241 | + $invoice_id = wp_update_post($invoice_data); |
|
| 242 | 242 | } else { |
| 243 | - $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true ); |
|
| 243 | + $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( is_wp_error( $invoice_id ) ) { |
|
| 246 | + if (is_wp_error($invoice_id)) { |
|
| 247 | 247 | return $invoice_id; |
| 248 | 248 | } else { |
| 249 | - if ( !$updating ) { |
|
| 250 | - $invoice_number = wpinv_format_invoice_number( $invoice_id ); |
|
| 249 | + if (!$updating) { |
|
| 250 | + $invoice_number = wpinv_format_invoice_number($invoice_id); |
|
| 251 | 251 | |
| 252 | - $update = array( 'ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title( $invoice_number ) ); |
|
| 253 | - wp_update_post( $update ); |
|
| 252 | + $update = array('ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title($invoice_number)); |
|
| 253 | + wp_update_post($update); |
|
| 254 | 254 | |
| 255 | - update_post_meta( $invoice_id, '_wpinv_number', $invoice_number ); |
|
| 255 | + update_post_meta($invoice_id, '_wpinv_number', $invoice_number); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( !$updating ) { |
|
| 260 | - update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) ); |
|
| 261 | - update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() ); |
|
| 262 | - update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) ); |
|
| 263 | - update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() ); |
|
| 264 | - update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() ); |
|
| 259 | + if (!$updating) { |
|
| 260 | + update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_'))); |
|
| 261 | + update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency()); |
|
| 262 | + update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax')); |
|
| 263 | + update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip()); |
|
| 264 | + update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent()); |
|
| 265 | 265 | ///update_post_meta( $invoice_id, '_wpinv_user_id', 0 ); |
| 266 | - update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) ); |
|
| 266 | + update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via'])); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | ///if ( is_numeric( $args['user_id'] ) ) { |
| 270 | 270 | ///update_post_meta( $invoice_id, '_wpinv_user_id', $args['user_id'] ); |
| 271 | 271 | ///} |
| 272 | 272 | |
| 273 | - update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION ); |
|
| 273 | + update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION); |
|
| 274 | 274 | |
| 275 | - return wpinv_get_invoice( $invoice_id ); |
|
| 275 | + return wpinv_get_invoice($invoice_id); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | function wpinv_get_prefix() { |
| 279 | 279 | $invoice_prefix = 'INV-'; |
| 280 | 280 | |
| 281 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
| 281 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | function wpinv_get_business_logo() { |
| 285 | - $business_logo = wpinv_get_option( 'logo' ); |
|
| 286 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
| 285 | + $business_logo = wpinv_get_option('logo'); |
|
| 286 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | function wpinv_get_business_name() { |
| 290 | 290 | $business_name = wpinv_get_option('store_name'); |
| 291 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
| 291 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | function wpinv_get_blogname() { |
| 295 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
| 295 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | function wpinv_get_admin_email() { |
| 299 | - $admin_email = get_option( 'admin_email' ); |
|
| 300 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
| 299 | + $admin_email = get_option('admin_email'); |
|
| 300 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | function wpinv_get_business_website() { |
| 304 | - $business_website = home_url( '/' ); |
|
| 305 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
| 304 | + $business_website = home_url('/'); |
|
| 305 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
| 308 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
| 309 | 309 | $terms_text = ''; |
| 310 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
| 310 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | function wpinv_get_business_footer() { |
| 314 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
| 315 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
| 316 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
| 314 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
| 315 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
| 316 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | function wpinv_checkout_required_fields() { |
| 320 | 320 | $required_fields = array(); |
| 321 | 321 | |
| 322 | 322 | // Let payment gateways and other extensions determine if address fields should be required |
| 323 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
| 323 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
| 324 | 324 | |
| 325 | - if ( $require_billing_details ) { |
|
| 325 | + if ($require_billing_details) { |
|
| 326 | 326 | ///$required_fields['email'] = array( |
| 327 | 327 | ///'error_id' => 'invalid_email', |
| 328 | 328 | ///'error_message' => __( 'Please enter a valid email address', 'invoicing' ) |
| 329 | 329 | ///); |
| 330 | 330 | $required_fields['first_name'] = array( |
| 331 | 331 | 'error_id' => 'invalid_first_name', |
| 332 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
| 332 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
| 333 | 333 | ); |
| 334 | 334 | $required_fields['address'] = array( |
| 335 | 335 | 'error_id' => 'invalid_address', |
| 336 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
| 336 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
| 337 | 337 | ); |
| 338 | 338 | $required_fields['city'] = array( |
| 339 | 339 | 'error_id' => 'invalid_city', |
| 340 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
| 340 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
| 341 | 341 | ); |
| 342 | 342 | $required_fields['state'] = array( |
| 343 | 343 | 'error_id' => 'invalid_state', |
| 344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
| 344 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
| 345 | 345 | ); |
| 346 | 346 | $required_fields['country'] = array( |
| 347 | 347 | 'error_id' => 'invalid_country', |
| 348 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
| 348 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
| 349 | 349 | ); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
| 352 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | function wpinv_is_ssl_enforced() { |
| 356 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
| 357 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
| 356 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
| 357 | + return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | -function wpinv_user_can_print_invoice( $post ) { |
|
| 360 | +function wpinv_user_can_print_invoice($post) { |
|
| 361 | 361 | $allow = false; |
| 362 | 362 | |
| 363 | - if ( !( $user_id = get_current_user_id() ) ) { |
|
| 363 | + if (!($user_id = get_current_user_id())) { |
|
| 364 | 364 | return $allow; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( is_int( $post ) ) { |
|
| 368 | - $post = get_post( $post ); |
|
| 367 | + if (is_int($post)) { |
|
| 368 | + $post = get_post($post); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | // Allow to owner. |
| 372 | - if ( is_object( $post ) && !empty( $post->post_author ) && $post->post_author == $user_id ) { |
|
| 372 | + if (is_object($post) && !empty($post->post_author) && $post->post_author == $user_id) { |
|
| 373 | 373 | $allow = true; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Allow to admin user. |
| 377 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 377 | + if (current_user_can('manage_options')) { |
|
| 378 | 378 | $allow = true; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - return apply_filters( 'wpinv_can_print_invoice', $allow, $post ); |
|
| 381 | + return apply_filters('wpinv_can_print_invoice', $allow, $post); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | function wpinv_schedule_events() { |
| 385 | 385 | // hourly, daily and twicedaily |
| 386 | - if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) { |
|
| 387 | - wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' ); |
|
| 386 | + if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) { |
|
| 387 | + wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily'); |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | -add_action( 'wp', 'wpinv_schedule_events' ); |
|
| 390 | +add_action('wp', 'wpinv_schedule_events'); |
|
| 391 | 391 | |
| 392 | 392 | function wpinv_schedule_event_twicedaily() { |
| 393 | 393 | wpinv_email_payment_reminders(); |
| 394 | 394 | } |
| 395 | -add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' ); |
|
| 396 | 395 | \ No newline at end of file |
| 396 | +add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily'); |
|
| 397 | 397 | \ No newline at end of file |
@@ -1,23 +1,23 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function wpinv_gd_active() { |
| 8 | - return (bool)defined( 'GEODIRECTORY_VERSION' ); |
|
| 8 | + return (bool)defined('GEODIRECTORY_VERSION'); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | function wpinv_pm_active() { |
| 12 | - return (bool)wpinv_gd_active() && (bool)defined( 'GEODIRPAYMENT_VERSION' ); |
|
| 12 | + return (bool)wpinv_gd_active() && (bool)defined('GEODIRPAYMENT_VERSION'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -function wpinv_is_gd_post_type( $post_type ) { |
|
| 15 | +function wpinv_is_gd_post_type($post_type) { |
|
| 16 | 16 | global $gd_posttypes; |
| 17 | 17 | |
| 18 | - $gd_posttypes = !empty( $gd_posttypes ) && is_array( $gd_posttypes ) ? $gd_posttypes : geodir_get_posttypes(); |
|
| 18 | + $gd_posttypes = !empty($gd_posttypes) && is_array($gd_posttypes) ? $gd_posttypes : geodir_get_posttypes(); |
|
| 19 | 19 | |
| 20 | - if ( !empty( $post_type ) && !empty( $gd_posttypes ) && in_array( $post_type, $gd_posttypes ) ) { |
|
| 20 | + if (!empty($post_type) && !empty($gd_posttypes) && in_array($post_type, $gd_posttypes)) { |
|
| 21 | 21 | return true; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
| 32 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 33 | 33 | // Add fields for force upgrade |
| 34 | - if ( defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column') ) { |
|
| 35 | - geodir_add_column_if_not_exist( INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0' ); |
|
| 34 | + if (defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column')) { |
|
| 35 | + geodir_add_column_if_not_exist(INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0'); |
|
| 36 | 36 | |
| 37 | 37 | update_option('wpinv_gdp_column', '1'); |
| 38 | 38 | } |
@@ -40,39 +40,39 @@ discard block |
||
| 40 | 40 | wpinv_merge_gd_packages_to_items(); |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | -add_action( 'admin_init', 'wpinv_geodir_integration' ); |
|
| 43 | +add_action('admin_init', 'wpinv_geodir_integration'); |
|
| 44 | 44 | |
| 45 | -function wpinv_get_gdp_package_type( $item_types ) { |
|
| 46 | - if ( wpinv_pm_active() ) { |
|
| 47 | - $item_types['package'] = __( 'Package', 'invoicing' ); |
|
| 45 | +function wpinv_get_gdp_package_type($item_types) { |
|
| 46 | + if (wpinv_pm_active()) { |
|
| 47 | + $item_types['package'] = __('Package', 'invoicing'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return $item_types; |
| 51 | 51 | } |
| 52 | -add_filter( 'wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1 ); |
|
| 52 | +add_filter('wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1); |
|
| 53 | 53 | |
| 54 | 54 | function wpinv_update_package_item($package_id) { |
| 55 | 55 | return wpinv_merge_gd_package_to_item($package_id, true); |
| 56 | 56 | } |
| 57 | 57 | add_action('geodir_after_save_package', 'wpinv_update_package_item', 10, 1); |
| 58 | 58 | |
| 59 | -function wpinv_merge_gd_packages_to_items( $force = false ) { |
|
| 60 | - if ( $merged = get_option( 'wpinv_merge_gd_packages' ) && !$force ) { |
|
| 59 | +function wpinv_merge_gd_packages_to_items($force = false) { |
|
| 60 | + if ($merged = get_option('wpinv_merge_gd_packages') && !$force) { |
|
| 61 | 61 | return true; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if(!function_exists('geodir_package_list_info')){ |
|
| 64 | + if (!function_exists('geodir_package_list_info')) { |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $packages = geodir_package_list_info(); |
| 69 | 69 | |
| 70 | - foreach ( $packages as $key => $package ) { |
|
| 71 | - wpinv_merge_gd_package_to_item( $package->pid, $force, $package ); |
|
| 70 | + foreach ($packages as $key => $package) { |
|
| 71 | + wpinv_merge_gd_package_to_item($package->pid, $force, $package); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( !$merged ) { |
|
| 75 | - update_option( 'wpinv_merge_gd_packages', 1 ); |
|
| 74 | + if (!$merged) { |
|
| 75 | + update_option('wpinv_merge_gd_packages', 1); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return true; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | $package = empty($package) ? geodir_get_package_info_by_id($package_id, '') : $package; |
| 103 | 103 | |
| 104 | - if ( empty($package) || !wpinv_is_gd_post_type( $package->post_type ) ) { |
|
| 104 | + if (empty($package) || !wpinv_is_gd_post_type($package->post_type)) { |
|
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -111,17 +111,17 @@ discard block |
||
| 111 | 111 | $meta['post_type'] = $package->post_type; |
| 112 | 112 | $meta['cpt_singular_name'] = get_post_type_singular_label($package->post_type); |
| 113 | 113 | $meta['cpt_name'] = get_post_type_plural_label($package->post_type); |
| 114 | - $meta['price'] = wpinv_format_amount( $package->amount, NULL, true ); |
|
| 114 | + $meta['price'] = wpinv_format_amount($package->amount, NULL, true); |
|
| 115 | 115 | $meta['vat_rule'] = 'digital'; |
| 116 | 116 | $meta['vat_class'] = '_standard'; |
| 117 | 117 | |
| 118 | - if ( !empty( $package->sub_active ) ) { |
|
| 119 | - $sub_num_trial_days = absint( $package->sub_num_trial_days ); |
|
| 118 | + if (!empty($package->sub_active)) { |
|
| 119 | + $sub_num_trial_days = absint($package->sub_num_trial_days); |
|
| 120 | 120 | |
| 121 | 121 | $meta['is_recurring'] = 1; |
| 122 | 122 | $meta['recurring_period'] = $package->sub_units; |
| 123 | - $meta['recurring_interval'] = absint( $package->sub_units_num ); |
|
| 124 | - $meta['recurring_limit'] = absint( $package->sub_units_num_times ); |
|
| 123 | + $meta['recurring_interval'] = absint($package->sub_units_num); |
|
| 124 | + $meta['recurring_limit'] = absint($package->sub_units_num_times); |
|
| 125 | 125 | $meta['free_trial'] = $sub_num_trial_days > 0 ? 1 : 0; |
| 126 | 126 | $meta['trial_period'] = $package->sub_num_trial_units; |
| 127 | 127 | $meta['trial_interval'] = $sub_num_trial_days; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $meta['trial_interval'] = ''; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $data = array( |
|
| 138 | + $data = array( |
|
| 139 | 139 | 'post_title' => $package->title, |
| 140 | 140 | 'post_excerpt' => $package->title_desc, |
| 141 | 141 | 'post_status' => $package->status == 1 ? 'publish' : 'pending', |
@@ -152,48 +152,48 @@ discard block |
||
| 152 | 152 | return $item; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -function wpinv_gdp_to_wpi_gateway( $payment_method ) { |
|
| 156 | - switch( $payment_method ) { |
|
| 155 | +function wpinv_gdp_to_wpi_gateway($payment_method) { |
|
| 156 | + switch ($payment_method) { |
|
| 157 | 157 | case 'prebanktransfer': |
| 158 | 158 | $gateway = 'bank_transfer'; |
| 159 | 159 | break; |
| 160 | 160 | default: |
| 161 | - $gateway = empty( $payment_method ) ? 'manual' : $payment_method; |
|
| 161 | + $gateway = empty($payment_method) ? 'manual' : $payment_method; |
|
| 162 | 162 | break; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - return apply_filters( 'wpinv_gdp_to_wpi_gateway', $gateway, $payment_method ); |
|
| 165 | + return apply_filters('wpinv_gdp_to_wpi_gateway', $gateway, $payment_method); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | -function wpinv_gdp_to_wpi_gateway_title( $payment_method ) { |
|
| 169 | - $gateway = wpinv_gdp_to_wpi_gateway( $payment_method ); |
|
| 168 | +function wpinv_gdp_to_wpi_gateway_title($payment_method) { |
|
| 169 | + $gateway = wpinv_gdp_to_wpi_gateway($payment_method); |
|
| 170 | 170 | |
| 171 | - $gateway_title = wpinv_get_gateway_checkout_label( $gateway ); |
|
| 171 | + $gateway_title = wpinv_get_gateway_checkout_label($gateway); |
|
| 172 | 172 | |
| 173 | - if ( $gateway == $gateway_title ) { |
|
| 174 | - $gateway_title = geodir_payment_method_title( $gateway ); |
|
| 173 | + if ($gateway == $gateway_title) { |
|
| 174 | + $gateway_title = geodir_payment_method_title($gateway); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - return apply_filters( 'wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method ); |
|
| 177 | + return apply_filters('wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | function wpinv_print_checkout_errors() { |
| 181 | 181 | global $wpi_session; |
| 182 | 182 | wpinv_print_errors(); |
| 183 | 183 | } |
| 184 | -add_action( 'geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10 ); |
|
| 184 | +add_action('geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10); |
|
| 185 | 185 | |
| 186 | -function wpinv_cpt_save( $invoice_id, $update = false, $pre_status = NULL ) { |
|
| 186 | +function wpinv_cpt_save($invoice_id, $update = false, $pre_status = NULL) { |
|
| 187 | 187 | global $wpi_nosave, $wpi_zero_tax, $wpi_gdp_inv_merge; |
| 188 | 188 | |
| 189 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
| 189 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
| 190 | 190 | |
| 191 | - $wpi_invoice_id = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : 0; |
|
| 191 | + $wpi_invoice_id = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : 0; |
|
| 192 | 192 | |
| 193 | 193 | if (!empty($invoice_info)) { |
| 194 | - $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice( $wpi_invoice_id ) : NULL; |
|
| 194 | + $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice($wpi_invoice_id) : NULL; |
|
| 195 | 195 | |
| 196 | - if ( !empty( $wpi_invoice ) ) { // update invoice |
|
| 196 | + if (!empty($wpi_invoice)) { // update invoice |
|
| 197 | 197 | $save = false; |
| 198 | 198 | if ($invoice_info->coupon_code !== $wpi_invoice->discount_code || (float)$invoice_info->discount < (float)$wpi_invoice->discount || (float)$invoice_info->discount > (float)$wpi_invoice->discount) { |
| 199 | 199 | $save = true; |
@@ -203,16 +203,16 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | if ($invoice_info->paymentmethod !== $wpi_invoice->gateway) { |
| 205 | 205 | $save = true; |
| 206 | - $gateway = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : ''; |
|
| 207 | - $gateway = wpinv_gdp_to_wpi_gateway( $gateway ); |
|
| 208 | - $gateway_title = wpinv_gdp_to_wpi_gateway_title( $gateway ); |
|
| 209 | - $wpi_invoice->set('gateway', $gateway ); |
|
| 210 | - $wpi_invoice->set('gateway_title', $gateway_title ); |
|
| 206 | + $gateway = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : ''; |
|
| 207 | + $gateway = wpinv_gdp_to_wpi_gateway($gateway); |
|
| 208 | + $gateway_title = wpinv_gdp_to_wpi_gateway_title($gateway); |
|
| 209 | + $wpi_invoice->set('gateway', $gateway); |
|
| 210 | + $wpi_invoice->set('gateway_title', $gateway_title); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( ( $status = wpinv_gdp_to_wpi_status( $invoice_info->status ) ) !== $wpi_invoice->status ) { |
|
| 213 | + if (($status = wpinv_gdp_to_wpi_status($invoice_info->status)) !== $wpi_invoice->status) { |
|
| 214 | 214 | $save = true; |
| 215 | - $wpi_invoice->set( 'status', $status ); |
|
| 215 | + $wpi_invoice->set('status', $status); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | if ($save) { |
@@ -223,37 +223,37 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | return $wpi_invoice; |
| 225 | 225 | } else { // create invoice |
| 226 | - $user_info = get_userdata( $invoice_info->user_id ); |
|
| 226 | + $user_info = get_userdata($invoice_info->user_id); |
|
| 227 | 227 | |
| 228 | - if ( !empty( $pre_status ) ) { |
|
| 228 | + if (!empty($pre_status)) { |
|
| 229 | 229 | $invoice_info->status = $pre_status; |
| 230 | 230 | } |
| 231 | - $status = wpinv_gdp_to_wpi_status( $invoice_info->status ); |
|
| 231 | + $status = wpinv_gdp_to_wpi_status($invoice_info->status); |
|
| 232 | 232 | |
| 233 | 233 | $wpi_zero_tax = false; |
| 234 | 234 | |
| 235 | - if ( $wpi_gdp_inv_merge && in_array( $status, array( 'publish', 'complete', 'processing', 'renewal' ) ) ) { |
|
| 235 | + if ($wpi_gdp_inv_merge && in_array($status, array('publish', 'complete', 'processing', 'renewal'))) { |
|
| 236 | 236 | $wpi_zero_tax = true; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $invoice_data = array(); |
| 240 | 240 | $invoice_data['invoice_id'] = $wpi_invoice_id; |
| 241 | 241 | $invoice_data['status'] = $status; |
| 242 | - if ( $update ) { |
|
| 242 | + if ($update) { |
|
| 243 | 243 | //$invoice_data['private_note'] = __( 'Invoice was updated.', 'invoicing' ); |
| 244 | 244 | } else { |
| 245 | - $invoice_data['private_note'] = wp_sprintf( __( 'Invoice was created with status %s.', 'invoicing' ), wpinv_status_nicename( $status ) ); |
|
| 245 | + $invoice_data['private_note'] = wp_sprintf(__('Invoice was created with status %s.', 'invoicing'), wpinv_status_nicename($status)); |
|
| 246 | 246 | } |
| 247 | 247 | $invoice_data['user_id'] = $invoice_info->user_id; |
| 248 | 248 | $invoice_data['created_via'] = 'API'; |
| 249 | 249 | |
| 250 | - if ( !empty( $invoice_info->date ) ) { |
|
| 251 | - $invoice_data['created_date'] = $invoice_info->date; |
|
| 250 | + if (!empty($invoice_info->date)) { |
|
| 251 | + $invoice_data['created_date'] = $invoice_info->date; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - $paymentmethod = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : ''; |
|
| 255 | - $paymentmethod = wpinv_gdp_to_wpi_gateway( $paymentmethod ); |
|
| 256 | - $payment_method_title = wpinv_gdp_to_wpi_gateway_title( $paymentmethod ); |
|
| 254 | + $paymentmethod = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : ''; |
|
| 255 | + $paymentmethod = wpinv_gdp_to_wpi_gateway($paymentmethod); |
|
| 256 | + $payment_method_title = wpinv_gdp_to_wpi_gateway_title($paymentmethod); |
|
| 257 | 257 | |
| 258 | 258 | $invoice_data['payment_details'] = array( |
| 259 | 259 | 'gateway' => $paymentmethod, |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | 'paid' => $status === 'publish' ? true : false |
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | - $user_address = wpinv_get_user_address( $invoice_info->user_id, false ); |
|
| 265 | + $user_address = wpinv_get_user_address($invoice_info->user_id, false); |
|
| 266 | 266 | |
| 267 | 267 | $invoice_data['user_info'] = array( |
| 268 | 268 | 'user_id' => $invoice_info->user_id, |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | $post_item = wpinv_get_gd_package_item($invoice_info->package_id); |
| 287 | 287 | |
| 288 | - if ( !empty( $post_item ) ) { |
|
| 289 | - $cart_details = array(); |
|
| 288 | + if (!empty($post_item)) { |
|
| 289 | + $cart_details = array(); |
|
| 290 | 290 | $cart_details[] = array( |
| 291 | 291 | 'id' => $post_item->ID, |
| 292 | 292 | 'name' => $post_item->get_name(), |
@@ -299,19 +299,19 @@ discard block |
||
| 299 | 299 | ), |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | - $invoice_data['cart_details'] = $cart_details; |
|
| 302 | + $invoice_data['cart_details'] = $cart_details; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $data = array( 'invoice' => $invoice_data ); |
|
| 305 | + $data = array('invoice' => $invoice_data); |
|
| 306 | 306 | |
| 307 | 307 | $wpinv_api = new WPInv_API(); |
| 308 | - $data = $wpinv_api->insert_invoice( $data ); |
|
| 308 | + $data = $wpinv_api->insert_invoice($data); |
|
| 309 | 309 | |
| 310 | - if ( is_wp_error( $data ) ) { |
|
| 311 | - wpinv_error_log( 'WPInv_Invoice: ' . $data->get_error_message() ); |
|
| 310 | + if (is_wp_error($data)) { |
|
| 311 | + wpinv_error_log('WPInv_Invoice: ' . $data->get_error_message()); |
|
| 312 | 312 | } else { |
| 313 | - if ( !empty( $data ) ) { |
|
| 314 | - update_post_meta( $data->ID, '_wpinv_gdp_id', $invoice_id ); |
|
| 313 | + if (!empty($data)) { |
|
| 314 | + update_post_meta($data->ID, '_wpinv_gdp_id', $invoice_id); |
|
| 315 | 315 | |
| 316 | 316 | global $wpi_userID, $wpinv_ip_address_country; |
| 317 | 317 | |
@@ -319,21 +319,21 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | $data_session = array(); |
| 321 | 321 | $data_session['invoice_id'] = $data->ID; |
| 322 | - $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
| 322 | + $data_session['cart_discounts'] = $data->get_discounts(true); |
|
| 323 | 323 | |
| 324 | - wpinv_set_checkout_session( $data_session ); |
|
| 324 | + wpinv_set_checkout_session($data_session); |
|
| 325 | 325 | |
| 326 | 326 | $wpi_userID = (int)$data->get_user_id(); |
| 327 | 327 | $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
| 328 | 328 | |
| 329 | - $data->country = sanitize_text_field( $_POST['country'] ); |
|
| 330 | - $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 329 | + $data->country = sanitize_text_field($_POST['country']); |
|
| 330 | + $data->set('country', sanitize_text_field($_POST['country'])); |
|
| 331 | 331 | |
| 332 | 332 | $wpinv_ip_address_country = $data->country; |
| 333 | 333 | |
| 334 | 334 | $data = $data->recalculate_totals(true); |
| 335 | 335 | |
| 336 | - wpinv_set_checkout_session( $checkout_session ); |
|
| 336 | + wpinv_set_checkout_session($checkout_session); |
|
| 337 | 337 | |
| 338 | 338 | $update_data = array(); |
| 339 | 339 | $update_data['tax_amount'] = $data->get_tax(); |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | $update_data['invoice_id'] = $data->ID; |
| 342 | 342 | |
| 343 | 343 | global $wpdb; |
| 344 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $invoice_id ) ); |
|
| 344 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $invoice_id)); |
|
| 345 | 345 | |
| 346 | 346 | return $data; |
| 347 | 347 | } else { |
| 348 | - if ( $update ) { |
|
| 349 | - wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to update invoice.', 'invoicing' ) ); |
|
| 348 | + if ($update) { |
|
| 349 | + wpinv_error_log('WPInv_Invoice: ' . __('Fail to update invoice.', 'invoicing')); |
|
| 350 | 350 | } else { |
| 351 | - wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to create invoice.', 'invoicing' ) ); |
|
| 351 | + wpinv_error_log('WPInv_Invoice: ' . __('Fail to create invoice.', 'invoicing')); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -359,59 +359,59 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | add_action('geodir_payment_invoice_created', 'wpinv_cpt_save', 11, 3); |
| 361 | 361 | |
| 362 | -function wpinv_cpt_update( $invoice_id ) { |
|
| 363 | - return wpinv_cpt_save( $invoice_id, true ); |
|
| 362 | +function wpinv_cpt_update($invoice_id) { |
|
| 363 | + return wpinv_cpt_save($invoice_id, true); |
|
| 364 | 364 | } |
| 365 | 365 | add_action('geodir_payment_invoice_updated', 'wpinv_cpt_update', 11, 1); |
| 366 | 366 | |
| 367 | -function wpinv_payment_status_changed( $invoice_id, $new_status, $old_status = 'pending', $subscription = false ) { |
|
| 368 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
| 369 | - if ( empty( $invoice_info ) ) { |
|
| 367 | +function wpinv_payment_status_changed($invoice_id, $new_status, $old_status = 'pending', $subscription = false) { |
|
| 368 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
| 369 | + if (empty($invoice_info)) { |
|
| 370 | 370 | return false; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - $invoice = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL; |
|
| 374 | - if ( !empty( $invoice ) ) { |
|
| 373 | + $invoice = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL; |
|
| 374 | + if (!empty($invoice)) { |
|
| 375 | 375 | $new_status = wpinv_gdp_to_wpi_status($new_status); |
| 376 | - $invoice = wpinv_update_payment_status( $invoice->ID, $new_status ); |
|
| 376 | + $invoice = wpinv_update_payment_status($invoice->ID, $new_status); |
|
| 377 | 377 | } else { |
| 378 | - $invoice = wpinv_cpt_save( $invoice_id ); |
|
| 378 | + $invoice = wpinv_cpt_save($invoice_id); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | return $invoice; |
| 382 | 382 | } |
| 383 | -add_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 ); |
|
| 383 | +add_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4); |
|
| 384 | 384 | |
| 385 | -function wpinv_transaction_details_note( $invoice_id, $html ) { |
|
| 386 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
| 387 | - if ( empty( $invoice_info ) ) { |
|
| 385 | +function wpinv_transaction_details_note($invoice_id, $html) { |
|
| 386 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
| 387 | + if (empty($invoice_info)) { |
|
| 388 | 388 | return false; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - $wpi_invoice_id = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : NULL; |
|
| 391 | + $wpi_invoice_id = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : NULL; |
|
| 392 | 392 | |
| 393 | - if ( !$wpi_invoice_id ) { |
|
| 394 | - $invoice = wpinv_cpt_save( $invoice_id, false, $old_status ); |
|
| 393 | + if (!$wpi_invoice_id) { |
|
| 394 | + $invoice = wpinv_cpt_save($invoice_id, false, $old_status); |
|
| 395 | 395 | |
| 396 | - if ( !empty( $invoice ) ) { |
|
| 396 | + if (!empty($invoice)) { |
|
| 397 | 397 | $wpi_invoice_id = $invoice->ID; |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $invoice = wpinv_get_invoice( $wpi_invoice_id ); |
|
| 401 | + $invoice = wpinv_get_invoice($wpi_invoice_id); |
|
| 402 | 402 | |
| 403 | - if ( empty( $invoice ) ) { |
|
| 403 | + if (empty($invoice)) { |
|
| 404 | 404 | return false; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - return $invoice->add_note( $html, true ); |
|
| 407 | + return $invoice->add_note($html, true); |
|
| 408 | 408 | } |
| 409 | -add_action( 'geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2 ); |
|
| 409 | +add_action('geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2); |
|
| 410 | 410 | |
| 411 | -function wpinv_gdp_to_wpi_status( $status ) { |
|
| 411 | +function wpinv_gdp_to_wpi_status($status) { |
|
| 412 | 412 | $inv_status = $status ? $status : 'pending'; |
| 413 | 413 | |
| 414 | - switch ( $status ) { |
|
| 414 | + switch ($status) { |
|
| 415 | 415 | case 'confirmed': |
| 416 | 416 | $inv_status = 'publish'; |
| 417 | 417 | break; |
@@ -420,10 +420,10 @@ discard block |
||
| 420 | 420 | return $inv_status; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | -function wpinv_wpi_to_gdp_status( $status ) { |
|
| 423 | +function wpinv_wpi_to_gdp_status($status) { |
|
| 424 | 424 | $inv_status = $status ? $status : 'pending'; |
| 425 | 425 | |
| 426 | - switch ( $status ) { |
|
| 426 | + switch ($status) { |
|
| 427 | 427 | case 'publish': |
| 428 | 428 | case 'complete': |
| 429 | 429 | case 'processing': |
@@ -435,98 +435,98 @@ discard block |
||
| 435 | 435 | return $inv_status; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | -function wpinv_wpi_to_gdp_id( $invoice_id ) { |
|
| 438 | +function wpinv_wpi_to_gdp_id($invoice_id) { |
|
| 439 | 439 | global $wpdb; |
| 440 | 440 | |
| 441 | - return $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array( (int)$invoice_id ) ) ); |
|
| 441 | + return $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array((int)$invoice_id))); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | -function wpinv_gdp_to_wpi_id( $invoice_id ) { |
|
| 445 | - $invoice = geodir_get_invoice( $invoice_id ); |
|
| 446 | - return ( empty( $invoice->invoice_id ) ? $invoice->invoice_id : false); |
|
| 444 | +function wpinv_gdp_to_wpi_id($invoice_id) { |
|
| 445 | + $invoice = geodir_get_invoice($invoice_id); |
|
| 446 | + return (empty($invoice->invoice_id) ? $invoice->invoice_id : false); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | -function wpinv_to_gdp_recalculate_total( $invoice, $wpi_nosave ) { |
|
| 449 | +function wpinv_to_gdp_recalculate_total($invoice, $wpi_nosave) { |
|
| 450 | 450 | global $wpdb; |
| 451 | 451 | |
| 452 | - if ( !empty( $wpi_nosave ) ) { |
|
| 452 | + if (!empty($wpi_nosave)) { |
|
| 453 | 453 | return; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - $gdp_invoice_id = wpinv_wpi_to_gdp_id( $invoice->ID ); |
|
| 456 | + $gdp_invoice_id = wpinv_wpi_to_gdp_id($invoice->ID); |
|
| 457 | 457 | |
| 458 | - if ( $gdp_invoice_id > 0 ) { |
|
| 458 | + if ($gdp_invoice_id > 0) { |
|
| 459 | 459 | $update_data = array(); |
| 460 | 460 | $update_data['tax_amount'] = $invoice->tax; |
| 461 | 461 | $update_data['paied_amount'] = $invoice->total; |
| 462 | 462 | $update_data['discount'] = $invoice->discount; |
| 463 | 463 | $update_data['coupon_code'] = $invoice->discount_code; |
| 464 | 464 | |
| 465 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $gdp_invoice_id ) ); |
|
| 465 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $gdp_invoice_id)); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | return; |
| 469 | 469 | } |
| 470 | 470 | //add_action( 'wpinv_invoice_recalculate_total', 'wpinv_to_gdp_recalculate_total', 10, 2 ); |
| 471 | 471 | |
| 472 | -function wpinv_gdp_to_wpi_invoice( $invoice_id ) { |
|
| 473 | - $invoice = geodir_get_invoice( $invoice_id ); |
|
| 474 | - if ( empty( $invoice->invoice_id ) ) { |
|
| 472 | +function wpinv_gdp_to_wpi_invoice($invoice_id) { |
|
| 473 | + $invoice = geodir_get_invoice($invoice_id); |
|
| 474 | + if (empty($invoice->invoice_id)) { |
|
| 475 | 475 | return false; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - return wpinv_get_invoice( $invoice->invoice_id ); |
|
| 478 | + return wpinv_get_invoice($invoice->invoice_id); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | -function wpinv_payment_set_coupon_code( $status, $invoice_id, $coupon_code ) { |
|
| 482 | - $invoice = wpinv_gdp_to_wpi_invoice( $invoice_id ); |
|
| 483 | - if ( empty( $invoice ) ) { |
|
| 481 | +function wpinv_payment_set_coupon_code($status, $invoice_id, $coupon_code) { |
|
| 482 | + $invoice = wpinv_gdp_to_wpi_invoice($invoice_id); |
|
| 483 | + if (empty($invoice)) { |
|
| 484 | 484 | return $status; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if ( $status === 1 || $status === 0 ) { |
|
| 488 | - if ( $status === 1 ) { |
|
| 489 | - $discount = geodir_get_discount_amount( $coupon_code, $invoice->get_subtotal() ); |
|
| 487 | + if ($status === 1 || $status === 0) { |
|
| 488 | + if ($status === 1) { |
|
| 489 | + $discount = geodir_get_discount_amount($coupon_code, $invoice->get_subtotal()); |
|
| 490 | 490 | } else { |
| 491 | 491 | $discount = ''; |
| 492 | 492 | $coupon_code = ''; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - $invoice->set( 'discount', $discount ); |
|
| 496 | - $invoice->set( 'discount_code', $coupon_code ); |
|
| 495 | + $invoice->set('discount', $discount); |
|
| 496 | + $invoice->set('discount_code', $coupon_code); |
|
| 497 | 497 | $invoice->save(); |
| 498 | 498 | $invoice->recalculate_total(); |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | return $status; |
| 502 | 502 | } |
| 503 | -add_filter( 'geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3 ); |
|
| 503 | +add_filter('geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3); |
|
| 504 | 504 | |
| 505 | -function wpinv_insert_invoice( $invoice_data = array() ) { |
|
| 506 | - if ( empty( $invoice_data ) ) { |
|
| 505 | +function wpinv_insert_invoice($invoice_data = array()) { |
|
| 506 | + if (empty($invoice_data)) { |
|
| 507 | 507 | return false; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | // default invoice args, note that status is checked for validity in wpinv_create_invoice() |
| 511 | 511 | $default_args = array( |
| 512 | - 'status' => !empty( $invoice_data['status'] ) ? $invoice_data['status'] : 'pending', |
|
| 513 | - 'user_note' => !empty( $invoice_data['note'] ) ? $invoice_data['note'] : null, |
|
| 514 | - 'invoice_id' => !empty( $invoice_data['invoice_id'] ) ? (int)$invoice_data['invoice_id'] : 0, |
|
| 515 | - 'user_id' => !empty( $invoice_data['user_id'] ) ? (int)$invoice_data['user_id'] : get_current_user_id(), |
|
| 512 | + 'status' => !empty($invoice_data['status']) ? $invoice_data['status'] : 'pending', |
|
| 513 | + 'user_note' => !empty($invoice_data['note']) ? $invoice_data['note'] : null, |
|
| 514 | + 'invoice_id' => !empty($invoice_data['invoice_id']) ? (int)$invoice_data['invoice_id'] : 0, |
|
| 515 | + 'user_id' => !empty($invoice_data['user_id']) ? (int)$invoice_data['user_id'] : get_current_user_id(), |
|
| 516 | 516 | ); |
| 517 | 517 | |
| 518 | - $invoice = wpinv_create_invoice( $default_args, $invoice_data ); |
|
| 519 | - if ( is_wp_error( $invoice ) ) { |
|
| 518 | + $invoice = wpinv_create_invoice($default_args, $invoice_data); |
|
| 519 | + if (is_wp_error($invoice)) { |
|
| 520 | 520 | return $invoice; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $gateway = !empty( $invoice_data['gateway'] ) ? $invoice_data['gateway'] : ''; |
|
| 524 | - $gateway = empty( $gateway ) && isset( $_POST['gateway'] ) ? $_POST['gateway'] : $gateway; |
|
| 523 | + $gateway = !empty($invoice_data['gateway']) ? $invoice_data['gateway'] : ''; |
|
| 524 | + $gateway = empty($gateway) && isset($_POST['gateway']) ? $_POST['gateway'] : $gateway; |
|
| 525 | 525 | |
| 526 | - if ( !empty( $gateway ) ) { |
|
| 527 | - $gateway = wpinv_gdp_to_wpi_gateway( $gateway ); |
|
| 526 | + if (!empty($gateway)) { |
|
| 527 | + $gateway = wpinv_gdp_to_wpi_gateway($gateway); |
|
| 528 | 528 | $invoice_data['payment_details']['gateway'] = $gateway; |
| 529 | - $invoice_data['payment_details']['gateway_title'] = wpinv_gdp_to_wpi_gateway_title( $gateway ); |
|
| 529 | + $invoice_data['payment_details']['gateway_title'] = wpinv_gdp_to_wpi_gateway_title($gateway); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | $user_info = array( |
@@ -547,67 +547,67 @@ discard block |
||
| 547 | 547 | 'discount' => array(), |
| 548 | 548 | ); |
| 549 | 549 | |
| 550 | - $user_info = wp_parse_args( $invoice_data['user_info'], $user_info ); |
|
| 550 | + $user_info = wp_parse_args($invoice_data['user_info'], $user_info); |
|
| 551 | 551 | |
| 552 | 552 | $payment_details = array(); |
| 553 | - if ( !empty( $invoice_data['payment_details'] ) ) { |
|
| 553 | + if (!empty($invoice_data['payment_details'])) { |
|
| 554 | 554 | $payment_details = array( |
| 555 | 555 | 'gateway' => 'manual', |
| 556 | - 'gateway_title' => __( 'Manual Payment', 'invoicing' ), |
|
| 556 | + 'gateway_title' => __('Manual Payment', 'invoicing'), |
|
| 557 | 557 | 'currency' => geodir_get_currency_type(), |
| 558 | 558 | 'paid' => false, |
| 559 | 559 | 'transaction_id' => '', |
| 560 | 560 | ); |
| 561 | - $payment_details = wp_parse_args( $invoice_data['payment_details'], $payment_details ); |
|
| 561 | + $payment_details = wp_parse_args($invoice_data['payment_details'], $payment_details); |
|
| 562 | 562 | } |
| 563 | - $invoice->set( 'status', ( !empty( $invoice_data['status'] ) ? $invoice_data['status'] : 'pending' ) ); |
|
| 564 | - if ( !empty( $payment_details ) ) { |
|
| 565 | - $invoice->set( 'currency', $payment_details['currency'] ); |
|
| 566 | - $invoice->set( 'gateway', $payment_details['gateway'] ); |
|
| 567 | - $invoice->set( 'gateway_title', $payment_details['gateway_title'] ); |
|
| 568 | - $invoice->set( 'transaction_id', $payment_details['transaction_id'] ); |
|
| 563 | + $invoice->set('status', (!empty($invoice_data['status']) ? $invoice_data['status'] : 'pending')); |
|
| 564 | + if (!empty($payment_details)) { |
|
| 565 | + $invoice->set('currency', $payment_details['currency']); |
|
| 566 | + $invoice->set('gateway', $payment_details['gateway']); |
|
| 567 | + $invoice->set('gateway_title', $payment_details['gateway_title']); |
|
| 568 | + $invoice->set('transaction_id', $payment_details['transaction_id']); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - $invoice->set( 'user_info', $user_info ); |
|
| 571 | + $invoice->set('user_info', $user_info); |
|
| 572 | 572 | ///$invoice->set( 'user_id', $user_info['user_id'] ); |
| 573 | 573 | ///$invoice->set( 'email', $user_info['email'] ); |
| 574 | - $invoice->set( 'first_name', $user_info['first_name'] ); |
|
| 575 | - $invoice->set( 'last_name', $user_info['last_name'] ); |
|
| 576 | - $invoice->set( 'address', $user_info['address'] ); |
|
| 577 | - $invoice->set( 'company', $user_info['company'] ); |
|
| 578 | - $invoice->set( 'vat_number', $user_info['vat_number'] ); |
|
| 579 | - $invoice->set( 'phone', $user_info['phone'] ); |
|
| 580 | - $invoice->set( 'city', $user_info['city'] ); |
|
| 581 | - $invoice->set( 'country', $user_info['country'] ); |
|
| 582 | - $invoice->set( 'state', $user_info['state'] ); |
|
| 583 | - $invoice->set( 'zip', $user_info['zip'] ); |
|
| 584 | - $invoice->set( 'discounts', ( !empty( $user_info['discount'] ) ? $user_info['discount'] : array() ) ); |
|
| 585 | - $invoice->set( 'ip', wpinv_get_ip() ); |
|
| 586 | - if ( !empty( $invoice_data['invoice_key'] ) ) { |
|
| 587 | - $invoice->set( 'key', $invoice_data['invoice_key'] ); |
|
| 574 | + $invoice->set('first_name', $user_info['first_name']); |
|
| 575 | + $invoice->set('last_name', $user_info['last_name']); |
|
| 576 | + $invoice->set('address', $user_info['address']); |
|
| 577 | + $invoice->set('company', $user_info['company']); |
|
| 578 | + $invoice->set('vat_number', $user_info['vat_number']); |
|
| 579 | + $invoice->set('phone', $user_info['phone']); |
|
| 580 | + $invoice->set('city', $user_info['city']); |
|
| 581 | + $invoice->set('country', $user_info['country']); |
|
| 582 | + $invoice->set('state', $user_info['state']); |
|
| 583 | + $invoice->set('zip', $user_info['zip']); |
|
| 584 | + $invoice->set('discounts', (!empty($user_info['discount']) ? $user_info['discount'] : array())); |
|
| 585 | + $invoice->set('ip', wpinv_get_ip()); |
|
| 586 | + if (!empty($invoice_data['invoice_key'])) { |
|
| 587 | + $invoice->set('key', $invoice_data['invoice_key']); |
|
| 588 | 588 | } |
| 589 | - $invoice->set( 'mode', ( wpinv_is_test_mode() ? 'test' : 'live' ) ); |
|
| 590 | - $invoice->set( 'parent_invoice', ( !empty( $invoice_data['parent'] ) ? absint( $invoice_data['parent'] ) : '' ) ); |
|
| 589 | + $invoice->set('mode', (wpinv_is_test_mode() ? 'test' : 'live')); |
|
| 590 | + $invoice->set('parent_invoice', (!empty($invoice_data['parent']) ? absint($invoice_data['parent']) : '')); |
|
| 591 | 591 | |
| 592 | 592 | // Add note |
| 593 | - if ( !empty( $invoice_data['user_note'] ) ) { |
|
| 594 | - $invoice->add_note( $invoice_data['user_note'], true ); |
|
| 593 | + if (!empty($invoice_data['user_note'])) { |
|
| 594 | + $invoice->add_note($invoice_data['user_note'], true); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - if ( !empty( $invoice_data['private_note'] ) ) { |
|
| 598 | - $invoice->add_note( $invoice_data['private_note'] ); |
|
| 597 | + if (!empty($invoice_data['private_note'])) { |
|
| 598 | + $invoice->add_note($invoice_data['private_note']); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if ( is_array( $invoice_data['cart_details'] ) && !empty( $invoice_data['cart_details'] ) ) { |
|
| 602 | - foreach ( $invoice_data['cart_details'] as $key => $item ) { |
|
| 603 | - $item_id = !empty( $item['id'] ) ? $item['id'] : 0; |
|
| 604 | - $quantity = !empty( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 605 | - $name = !empty( $item['name'] ) ? $item['name'] : ''; |
|
| 606 | - $item_price = isset( $item['item_price'] ) ? $item['item_price'] : ''; |
|
| 601 | + if (is_array($invoice_data['cart_details']) && !empty($invoice_data['cart_details'])) { |
|
| 602 | + foreach ($invoice_data['cart_details'] as $key => $item) { |
|
| 603 | + $item_id = !empty($item['id']) ? $item['id'] : 0; |
|
| 604 | + $quantity = !empty($item['quantity']) ? $item['quantity'] : 1; |
|
| 605 | + $name = !empty($item['name']) ? $item['name'] : ''; |
|
| 606 | + $item_price = isset($item['item_price']) ? $item['item_price'] : ''; |
|
| 607 | 607 | |
| 608 | - $post_item = new WPInv_Item( $item_id ); |
|
| 609 | - if ( !empty( $post_item ) ) { |
|
| 610 | - $name = !empty( $name ) ? $name : $post_item->get_name(); |
|
| 608 | + $post_item = new WPInv_Item($item_id); |
|
| 609 | + if (!empty($post_item)) { |
|
| 610 | + $name = !empty($name) ? $name : $post_item->get_name(); |
|
| 611 | 611 | $item_price = $item_price !== '' ? $item_price : $post_item->get_price(); |
| 612 | 612 | } else { |
| 613 | 613 | continue; |
@@ -617,33 +617,33 @@ discard block |
||
| 617 | 617 | 'name' => $name, |
| 618 | 618 | 'quantity' => $quantity, |
| 619 | 619 | 'item_price' => $item_price, |
| 620 | - 'tax' => !empty( $item['tax'] ) ? $item['tax'] : 0.00, |
|
| 621 | - 'discount' => isset( $item['discount'] ) ? $item['discount'] : 0, |
|
| 622 | - 'meta' => isset( $item['meta'] ) ? $item['meta'] : array(), |
|
| 623 | - 'fees' => isset( $item['fees'] ) ? $item['fees'] : array(), |
|
| 620 | + 'tax' => !empty($item['tax']) ? $item['tax'] : 0.00, |
|
| 621 | + 'discount' => isset($item['discount']) ? $item['discount'] : 0, |
|
| 622 | + 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
|
| 623 | + 'fees' => isset($item['fees']) ? $item['fees'] : array(), |
|
| 624 | 624 | ); |
| 625 | 625 | |
| 626 | - $invoice->add_item( $item_id, $args ); |
|
| 626 | + $invoice->add_item($item_id, $args); |
|
| 627 | 627 | } |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - $invoice->increase_tax( wpinv_get_cart_fee_tax() ); |
|
| 630 | + $invoice->increase_tax(wpinv_get_cart_fee_tax()); |
|
| 631 | 631 | |
| 632 | - if ( isset( $invoice_data['post_date'] ) ) { |
|
| 633 | - $invoice->set( 'date', $invoice_data['post_date'] ); |
|
| 632 | + if (isset($invoice_data['post_date'])) { |
|
| 633 | + $invoice->set('date', $invoice_data['post_date']); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - $number = wpinv_format_invoice_number( $invoice->ID ); |
|
| 637 | - $invoice->set( 'number', $number ); |
|
| 638 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
| 636 | + $number = wpinv_format_invoice_number($invoice->ID); |
|
| 637 | + $invoice->set('number', $number); |
|
| 638 | + update_option('wpinv_last_invoice_number', $number); |
|
| 639 | 639 | |
| 640 | 640 | $invoice->save(); |
| 641 | 641 | |
| 642 | - do_action( 'wpinv_insert_invoice', $invoice->ID, $invoice_data ); |
|
| 642 | + do_action('wpinv_insert_invoice', $invoice->ID, $invoice_data); |
|
| 643 | 643 | |
| 644 | - if ( ! empty( $invoice->ID ) ) { |
|
| 644 | + if (!empty($invoice->ID)) { |
|
| 645 | 645 | // payment method (and payment_complete() if `paid` == true) |
| 646 | - if ( !empty( $payment_details['paid'] ) ) { |
|
| 646 | + if (!empty($payment_details['paid'])) { |
|
| 647 | 647 | //$invoice->payment_complete( !empty( $payment_details['transaction_id'] ) ? $payment_details['transaction_id'] : $invoice->ID ); |
| 648 | 648 | } |
| 649 | 649 | |
@@ -660,158 +660,158 @@ discard block |
||
| 660 | 660 | } |
| 661 | 661 | ?> |
| 662 | 662 | <tr> |
| 663 | - <td><?php _e( 'Merge Price Packages', 'invoicing' ); ?></td> |
|
| 664 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing' ); ?></p></td> |
|
| 665 | - <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
| 663 | + <td><?php _e('Merge Price Packages', 'invoicing'); ?></td> |
|
| 664 | + <td><p><?php _e('Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing'); ?></p></td> |
|
| 665 | + <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
| 666 | 666 | </tr> |
| 667 | 667 | <tr> |
| 668 | - <td><?php _e( 'Merge Invoices', 'invoicing' ); ?></td> |
|
| 669 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing' ); ?></p></td> |
|
| 670 | - <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
| 668 | + <td><?php _e('Merge Invoices', 'invoicing'); ?></td> |
|
| 669 | + <td><p><?php _e('Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing'); ?></p></td> |
|
| 670 | + <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
| 671 | 671 | </tr> |
| 672 | 672 | <tr> |
| 673 | - <td><?php _e( 'Fix Taxes for Merged Invoices', 'invoicing' ); ?></td> |
|
| 674 | - <td><p><?php _e( 'Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing' ); ?></p></td> |
|
| 675 | - <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
| 673 | + <td><?php _e('Fix Taxes for Merged Invoices', 'invoicing'); ?></td> |
|
| 674 | + <td><p><?php _e('Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing'); ?></p></td> |
|
| 675 | + <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
| 676 | 676 | </tr> |
| 677 | 677 | <tr> |
| 678 | - <td><?php _e( 'Merge Coupons', 'invoicing' ); ?></td> |
|
| 679 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing' ); ?></p></td> |
|
| 680 | - <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
| 678 | + <td><?php _e('Merge Coupons', 'invoicing'); ?></td> |
|
| 679 | + <td><p><?php _e('Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing'); ?></p></td> |
|
| 680 | + <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
| 681 | 681 | </tr> |
| 682 | 682 | <?php |
| 683 | 683 | } |
| 684 | -add_action( 'wpinv_tools_row', 'wpinv_merge_gd_invoices', 10 ); |
|
| 684 | +add_action('wpinv_tools_row', 'wpinv_merge_gd_invoices', 10); |
|
| 685 | 685 | |
| 686 | 686 | function wpinv_tool_merge_packages() { |
| 687 | 687 | $packages = geodir_package_list_info(); |
| 688 | 688 | |
| 689 | 689 | $count = 0; |
| 690 | 690 | |
| 691 | - if ( !empty( $packages ) ) { |
|
| 691 | + if (!empty($packages)) { |
|
| 692 | 692 | $success = true; |
| 693 | 693 | |
| 694 | - foreach ( $packages as $key => $package ) { |
|
| 694 | + foreach ($packages as $key => $package) { |
|
| 695 | 695 | $item = wpinv_get_item_by('package_id', $package->pid); |
| 696 | - if ( !empty( $item ) ) { |
|
| 696 | + if (!empty($item)) { |
|
| 697 | 697 | continue; |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - $merged = wpinv_merge_gd_package_to_item( $package->pid, false, $package ); |
|
| 700 | + $merged = wpinv_merge_gd_package_to_item($package->pid, false, $package); |
|
| 701 | 701 | |
| 702 | - if ( !empty( $merged ) ) { |
|
| 703 | - wpinv_error_log( 'Package merge S : ' . $package->pid ); |
|
| 702 | + if (!empty($merged)) { |
|
| 703 | + wpinv_error_log('Package merge S : ' . $package->pid); |
|
| 704 | 704 | $count++; |
| 705 | 705 | } else { |
| 706 | - wpinv_error_log( 'Package merge F : ' . $package->pid ); |
|
| 706 | + wpinv_error_log('Package merge F : ' . $package->pid); |
|
| 707 | 707 | } |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - if ( $count > 0 ) { |
|
| 711 | - $message = sprintf( _n( 'Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing' ), $count ); |
|
| 710 | + if ($count > 0) { |
|
| 711 | + $message = sprintf(_n('Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing'), $count); |
|
| 712 | 712 | } else { |
| 713 | - $message = __( 'No price packages merged.', 'invoicing' ); |
|
| 713 | + $message = __('No price packages merged.', 'invoicing'); |
|
| 714 | 714 | } |
| 715 | 715 | } else { |
| 716 | 716 | $success = false; |
| 717 | - $message = __( 'No price packages found to merge!', 'invoicing' ); |
|
| 717 | + $message = __('No price packages found to merge!', 'invoicing'); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | $response = array(); |
| 721 | 721 | $response['success'] = $success; |
| 722 | 722 | $response['data']['message'] = $message; |
| 723 | - wp_send_json( $response ); |
|
| 723 | + wp_send_json($response); |
|
| 724 | 724 | } |
| 725 | -add_action( 'wpinv_tool_merge_packages', 'wpinv_tool_merge_packages' ); |
|
| 725 | +add_action('wpinv_tool_merge_packages', 'wpinv_tool_merge_packages'); |
|
| 726 | 726 | |
| 727 | 727 | function wpinv_tool_merge_invoices() { |
| 728 | 728 | global $wpdb, $wpi_gdp_inv_merge, $wpi_tax_rates; |
| 729 | 729 | |
| 730 | 730 | $sql = "SELECT `gdi`.`id`, `gdi`.`date`, `gdi`.`date_updated` FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NULL ORDER BY `gdi`.`id` ASC"; |
| 731 | - $items = $wpdb->get_results( $sql ); |
|
| 731 | + $items = $wpdb->get_results($sql); |
|
| 732 | 732 | |
| 733 | 733 | $count = 0; |
| 734 | 734 | |
| 735 | - if ( !empty( $items ) ) { |
|
| 735 | + if (!empty($items)) { |
|
| 736 | 736 | $success = true; |
| 737 | 737 | $wpi_gdp_inv_merge = true; |
| 738 | 738 | |
| 739 | - foreach ( $items as $item ) { |
|
| 739 | + foreach ($items as $item) { |
|
| 740 | 740 | $wpi_tax_rates = NULL; |
| 741 | 741 | |
| 742 | - $wpdb->query( "UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'" ); |
|
| 742 | + $wpdb->query("UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'"); |
|
| 743 | 743 | |
| 744 | - $merged = wpinv_cpt_save( $item->id ); |
|
| 744 | + $merged = wpinv_cpt_save($item->id); |
|
| 745 | 745 | |
| 746 | - if ( !empty( $merged ) && !empty( $merged->ID ) ) { |
|
| 746 | + if (!empty($merged) && !empty($merged->ID)) { |
|
| 747 | 747 | $count++; |
| 748 | 748 | |
| 749 | 749 | //$wpdb->query( "UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = '" . $merged->ID . "' WHERE id = '" . $item->id . "'" ); |
| 750 | 750 | |
| 751 | - $post_date = !empty( $item->date ) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time( 'mysql' ); |
|
| 752 | - $post_date_gmt = get_gmt_from_date( $post_date ); |
|
| 753 | - $post_modified = !empty( $item->date_updated ) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date; |
|
| 754 | - $post_modified_gmt = get_gmt_from_date( $post_modified ); |
|
| 751 | + $post_date = !empty($item->date) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time('mysql'); |
|
| 752 | + $post_date_gmt = get_gmt_from_date($post_date); |
|
| 753 | + $post_modified = !empty($item->date_updated) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date; |
|
| 754 | + $post_modified_gmt = get_gmt_from_date($post_modified); |
|
| 755 | 755 | |
| 756 | - $wpdb->update( $wpdb->posts, array( 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt ), array( 'ID' => $merged->ID ) ); |
|
| 756 | + $wpdb->update($wpdb->posts, array('post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt), array('ID' => $merged->ID)); |
|
| 757 | 757 | |
| 758 | - if ( $merged->is_paid() ) { |
|
| 759 | - update_post_meta( $merged->ID, '_wpinv_completed_date', $post_modified ); |
|
| 758 | + if ($merged->is_paid()) { |
|
| 759 | + update_post_meta($merged->ID, '_wpinv_completed_date', $post_modified); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - clean_post_cache( $merged->ID ); |
|
| 762 | + clean_post_cache($merged->ID); |
|
| 763 | 763 | |
| 764 | - wpinv_error_log( 'Invoice merge S : ' . $item->id . ' => ' . $merged->ID ); |
|
| 764 | + wpinv_error_log('Invoice merge S : ' . $item->id . ' => ' . $merged->ID); |
|
| 765 | 765 | } else { |
| 766 | - wpinv_error_log( 'Invoice merge F : ' . $item->id ); |
|
| 766 | + wpinv_error_log('Invoice merge F : ' . $item->id); |
|
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | $wpi_gdp_inv_merge = false; |
| 771 | 771 | |
| 772 | - if ( $count > 0 ) { |
|
| 773 | - $message = sprintf( _n( 'Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing' ), $count ); |
|
| 772 | + if ($count > 0) { |
|
| 773 | + $message = sprintf(_n('Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing'), $count); |
|
| 774 | 774 | } else { |
| 775 | - $message = __( 'No invoices merged.', 'invoicing' ); |
|
| 775 | + $message = __('No invoices merged.', 'invoicing'); |
|
| 776 | 776 | } |
| 777 | 777 | } else { |
| 778 | 778 | $success = false; |
| 779 | - $message = __( 'No invoices found to merge!', 'invoicing' ); |
|
| 779 | + $message = __('No invoices found to merge!', 'invoicing'); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | $response = array(); |
| 783 | 783 | $response['success'] = $success; |
| 784 | 784 | $response['data']['message'] = $message; |
| 785 | - wp_send_json( $response ); |
|
| 785 | + wp_send_json($response); |
|
| 786 | 786 | } |
| 787 | -add_action( 'wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices' ); |
|
| 787 | +add_action('wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices'); |
|
| 788 | 788 | |
| 789 | 789 | function wpinv_tool_merge_coupons() { |
| 790 | 790 | global $wpdb; |
| 791 | 791 | |
| 792 | 792 | $sql = "SELECT * FROM `" . COUPON_TABLE . "` WHERE `coupon_code` IS NOT NULL AND `coupon_code` != '' ORDER BY `cid` ASC"; |
| 793 | - $items = $wpdb->get_results( $sql ); |
|
| 793 | + $items = $wpdb->get_results($sql); |
|
| 794 | 794 | $count = 0; |
| 795 | 795 | |
| 796 | - if ( !empty( $items ) ) { |
|
| 796 | + if (!empty($items)) { |
|
| 797 | 797 | $success = true; |
| 798 | 798 | |
| 799 | - foreach ( $items as $item ) { |
|
| 800 | - if ( wpinv_get_discount_by_code( $item->coupon_code ) ) { |
|
| 799 | + foreach ($items as $item) { |
|
| 800 | + if (wpinv_get_discount_by_code($item->coupon_code)) { |
|
| 801 | 801 | continue; |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | $args = array( |
| 805 | 805 | 'post_type' => 'wpi_discount', |
| 806 | 806 | 'post_title' => $item->coupon_code, |
| 807 | - 'post_status' => !empty( $item->status ) ? 'publish' : 'pending' |
|
| 807 | + 'post_status' => !empty($item->status) ? 'publish' : 'pending' |
|
| 808 | 808 | ); |
| 809 | 809 | |
| 810 | - $merged = wp_insert_post( $args ); |
|
| 810 | + $merged = wp_insert_post($args); |
|
| 811 | 811 | |
| 812 | 812 | $item_id = $item->cid; |
| 813 | 813 | |
| 814 | - if ( $merged ) { |
|
| 814 | + if ($merged) { |
|
| 815 | 815 | $meta = array( |
| 816 | 816 | 'code' => $item->coupon_code, |
| 817 | 817 | 'type' => $item->discount_type != 'per' ? 'flat' : 'percent', |
@@ -819,65 +819,65 @@ discard block |
||
| 819 | 819 | 'max_uses' => (int)$item->usage_limit, |
| 820 | 820 | 'uses' => (int)$item->usage_count, |
| 821 | 821 | ); |
| 822 | - wpinv_store_discount( $merged, $meta, get_post( $merged ) ); |
|
| 822 | + wpinv_store_discount($merged, $meta, get_post($merged)); |
|
| 823 | 823 | |
| 824 | 824 | $count++; |
| 825 | 825 | |
| 826 | - wpinv_error_log( 'Coupon merge S : ' . $item_id . ' => ' . $merged ); |
|
| 826 | + wpinv_error_log('Coupon merge S : ' . $item_id . ' => ' . $merged); |
|
| 827 | 827 | } else { |
| 828 | - wpinv_error_log( 'Coupon merge F : ' . $item_id ); |
|
| 828 | + wpinv_error_log('Coupon merge F : ' . $item_id); |
|
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - if ( $count > 0 ) { |
|
| 833 | - $message = sprintf( _n( 'Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing' ), $count ); |
|
| 832 | + if ($count > 0) { |
|
| 833 | + $message = sprintf(_n('Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing'), $count); |
|
| 834 | 834 | } else { |
| 835 | - $message = __( 'No coupons merged.', 'invoicing' ); |
|
| 835 | + $message = __('No coupons merged.', 'invoicing'); |
|
| 836 | 836 | } |
| 837 | 837 | } else { |
| 838 | 838 | $success = false; |
| 839 | - $message = __( 'No coupons found to merge!', 'invoicing' ); |
|
| 839 | + $message = __('No coupons found to merge!', 'invoicing'); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | $response = array(); |
| 843 | 843 | $response['success'] = $success; |
| 844 | 844 | $response['data']['message'] = $message; |
| 845 | - wp_send_json( $response ); |
|
| 845 | + wp_send_json($response); |
|
| 846 | 846 | } |
| 847 | -add_action( 'wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons' ); |
|
| 847 | +add_action('wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons'); |
|
| 848 | 848 | |
| 849 | -function wpinv_gdp_to_wpi_currency( $value, $option = '' ) { |
|
| 849 | +function wpinv_gdp_to_wpi_currency($value, $option = '') { |
|
| 850 | 850 | return wpinv_get_currency(); |
| 851 | 851 | } |
| 852 | -add_filter( 'pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2 ); |
|
| 852 | +add_filter('pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2); |
|
| 853 | 853 | |
| 854 | -function wpinv_gdp_to_wpi_currency_sign( $value, $option = '' ) { |
|
| 854 | +function wpinv_gdp_to_wpi_currency_sign($value, $option = '') { |
|
| 855 | 855 | return wpinv_currency_symbol(); |
| 856 | 856 | } |
| 857 | -add_filter( 'pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2 ); |
|
| 857 | +add_filter('pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2); |
|
| 858 | 858 | |
| 859 | -function wpinv_gdp_to_wpi_display_price( $price, $amount, $display = true , $decimal_sep, $thousand_sep ) { |
|
| 860 | - if ( !$display ) { |
|
| 861 | - $price = wpinv_format_amount( $amount, NULL, true ); |
|
| 859 | +function wpinv_gdp_to_wpi_display_price($price, $amount, $display = true, $decimal_sep, $thousand_sep) { |
|
| 860 | + if (!$display) { |
|
| 861 | + $price = wpinv_format_amount($amount, NULL, true); |
|
| 862 | 862 | } else { |
| 863 | - $price = wpinv_price( wpinv_format_amount( $amount ) ); |
|
| 863 | + $price = wpinv_price(wpinv_format_amount($amount)); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | return $price; |
| 867 | 867 | } |
| 868 | -add_filter( 'geodir_payment_price' , 'wpinv_gdp_to_wpi_display_price', 10000, 5 ); |
|
| 868 | +add_filter('geodir_payment_price', 'wpinv_gdp_to_wpi_display_price', 10000, 5); |
|
| 869 | 869 | |
| 870 | -function wpinv_gdp_to_inv_checkout_redirect( $redirect_url ) { |
|
| 870 | +function wpinv_gdp_to_inv_checkout_redirect($redirect_url) { |
|
| 871 | 871 | $invoice_id = geodir_payment_cart_id(); |
| 872 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
| 873 | - $wpi_invoice = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL; |
|
| 872 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
| 873 | + $wpi_invoice = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL; |
|
| 874 | 874 | |
| 875 | - if ( !( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) ) { |
|
| 876 | - $wpi_invoice_id = wpinv_cpt_save( $invoice_id ); |
|
| 877 | - $wpi_invoice = wpinv_get_invoice( $wpi_invoice_id ); |
|
| 875 | + if (!(!empty($wpi_invoice) && !empty($wpi_invoice->ID))) { |
|
| 876 | + $wpi_invoice_id = wpinv_cpt_save($invoice_id); |
|
| 877 | + $wpi_invoice = wpinv_get_invoice($wpi_invoice_id); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - if ( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) { |
|
| 880 | + if (!empty($wpi_invoice) && !empty($wpi_invoice->ID)) { |
|
| 881 | 881 | |
| 882 | 882 | // Clear cart |
| 883 | 883 | geodir_payment_clear_cart(); |
@@ -887,121 +887,121 @@ discard block |
||
| 887 | 887 | |
| 888 | 888 | return $redirect_url; |
| 889 | 889 | } |
| 890 | -add_filter( 'geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1 ); |
|
| 890 | +add_filter('geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1); |
|
| 891 | 891 | |
| 892 | -function wpinv_gdp_dashboard_invoice_history_link( $dashboard_links ) { |
|
| 893 | - if ( get_current_user_id() ) { |
|
| 894 | - $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url( wpinv_get_history_page_uri() ) . '">' . __( 'My Invoice History', 'invoicing' ) . '</a></li>'; |
|
| 892 | +function wpinv_gdp_dashboard_invoice_history_link($dashboard_links) { |
|
| 893 | + if (get_current_user_id()) { |
|
| 894 | + $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url(wpinv_get_history_page_uri()) . '">' . __('My Invoice History', 'invoicing') . '</a></li>'; |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | return $dashboard_links; |
| 898 | 898 | } |
| 899 | -add_action( 'geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link' ); |
|
| 900 | -remove_action( 'geodir_dashboard_links', 'geodir_payment_invoices_list_page_link' ); |
|
| 899 | +add_action('geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link'); |
|
| 900 | +remove_action('geodir_dashboard_links', 'geodir_payment_invoices_list_page_link'); |
|
| 901 | 901 | |
| 902 | -function wpinv_wpi_to_gdp_update_status( $invoice_id, $new_status, $old_status ) { |
|
| 902 | +function wpinv_wpi_to_gdp_update_status($invoice_id, $new_status, $old_status) { |
|
| 903 | 903 | if (!defined('GEODIRPAYMENT_VERSION')) { |
| 904 | 904 | return false; |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 908 | - if ( empty( $invoice ) ) { |
|
| 907 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 908 | + if (empty($invoice)) { |
|
| 909 | 909 | return false; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - remove_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 ); |
|
| 912 | + remove_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4); |
|
| 913 | 913 | |
| 914 | - $invoice_id = wpinv_wpi_to_gdp_id( $invoice_id ); |
|
| 915 | - $new_status = wpinv_wpi_to_gdp_status( $new_status ); |
|
| 914 | + $invoice_id = wpinv_wpi_to_gdp_id($invoice_id); |
|
| 915 | + $new_status = wpinv_wpi_to_gdp_status($new_status); |
|
| 916 | 916 | |
| 917 | - geodir_update_invoice_status( $invoice_id, $new_status, $invoice->is_recurring() ); |
|
| 917 | + geodir_update_invoice_status($invoice_id, $new_status, $invoice->is_recurring()); |
|
| 918 | 918 | } |
| 919 | -add_action( 'wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3 ); |
|
| 919 | +add_action('wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3); |
|
| 920 | 920 | |
| 921 | -function wpinv_gdp_to_wpi_delete_package( $gd_package_id ) { |
|
| 922 | - $item = wpinv_get_item_by( 'package_id', $gd_package_id ); |
|
| 921 | +function wpinv_gdp_to_wpi_delete_package($gd_package_id) { |
|
| 922 | + $item = wpinv_get_item_by('package_id', $gd_package_id); |
|
| 923 | 923 | |
| 924 | - if ( !empty( $item ) ) { |
|
| 925 | - wpinv_remove_item( $item, true ); |
|
| 924 | + if (!empty($item)) { |
|
| 925 | + wpinv_remove_item($item, true); |
|
| 926 | 926 | } |
| 927 | 927 | } |
| 928 | -add_action( 'geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1 ) ; |
|
| 928 | +add_action('geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1); |
|
| 929 | 929 | |
| 930 | -function wpinv_can_delete_package_item( $return, $post_id ) { |
|
| 931 | - if ( $return && function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && $package_id = get_post_meta( $post_id, '_wpinv_package_id', true ) ) { |
|
| 932 | - $gd_package = geodir_get_package_info_by_id( $package_id, '' ); |
|
| 930 | +function wpinv_can_delete_package_item($return, $post_id) { |
|
| 931 | + if ($return && function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && $package_id = get_post_meta($post_id, '_wpinv_package_id', true)) { |
|
| 932 | + $gd_package = geodir_get_package_info_by_id($package_id, ''); |
|
| 933 | 933 | |
| 934 | - if ( !empty( $gd_package ) ) { |
|
| 934 | + if (!empty($gd_package)) { |
|
| 935 | 935 | $return = false; |
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | return $return; |
| 940 | 940 | } |
| 941 | -add_filter( 'wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2 ); |
|
| 941 | +add_filter('wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2); |
|
| 942 | 942 | |
| 943 | -function wpinv_package_item_classes( $classes, $class, $post_id ) { |
|
| 943 | +function wpinv_package_item_classes($classes, $class, $post_id) { |
|
| 944 | 944 | global $typenow; |
| 945 | 945 | |
| 946 | - if ( $typenow == 'wpi_item' && in_array( 'wpi-gd-package', $classes ) ) { |
|
| 947 | - if ( wpinv_item_in_use( $post_id ) ) { |
|
| 946 | + if ($typenow == 'wpi_item' && in_array('wpi-gd-package', $classes)) { |
|
| 947 | + if (wpinv_item_in_use($post_id)) { |
|
| 948 | 948 | $classes[] = 'wpi-inuse-pkg'; |
| 949 | - } else if ( !( function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && geodir_get_package_info_by_id( (int)get_post_meta( $post_id, '_wpinv_package_id', true ), '' ) ) ) { |
|
| 949 | + } else if (!(function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && geodir_get_package_info_by_id((int)get_post_meta($post_id, '_wpinv_package_id', true), ''))) { |
|
| 950 | 950 | $classes[] = 'wpi-delete-pkg'; |
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | return $classes; |
| 955 | 955 | } |
| 956 | -add_filter( 'post_class', 'wpinv_package_item_classes', 10, 3 ); |
|
| 956 | +add_filter('post_class', 'wpinv_package_item_classes', 10, 3); |
|
| 957 | 957 | |
| 958 | -function wpinv_gdp_package_type_info( $post ) { |
|
| 959 | - if ( wpinv_pm_active() ) { |
|
| 960 | - ?><p class="wpi-m0"><?php _e( 'Package: GeoDirectory price packages items.', 'invoicing' );?></p> |
|
| 958 | +function wpinv_gdp_package_type_info($post) { |
|
| 959 | + if (wpinv_pm_active()) { |
|
| 960 | + ?><p class="wpi-m0"><?php _e('Package: GeoDirectory price packages items.', 'invoicing'); ?></p> |
|
| 961 | 961 | <?php |
| 962 | 962 | } |
| 963 | 963 | } |
| 964 | -add_action( 'wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1 ) ; |
|
| 964 | +add_action('wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1); |
|
| 965 | 965 | |
| 966 | -function wpinv_gdp_to_gdi_set_zero_tax( $is_taxable, $item_id, $country , $state ) { |
|
| 966 | +function wpinv_gdp_to_gdi_set_zero_tax($is_taxable, $item_id, $country, $state) { |
|
| 967 | 967 | global $wpi_zero_tax; |
| 968 | 968 | |
| 969 | - if ( $wpi_zero_tax ) { |
|
| 969 | + if ($wpi_zero_tax) { |
|
| 970 | 970 | $is_taxable = false; |
| 971 | 971 | } |
| 972 | 972 | |
| 973 | 973 | return $is_taxable; |
| 974 | 974 | } |
| 975 | -add_action( 'wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4 ) ; |
|
| 975 | +add_action('wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4); |
|
| 976 | 976 | |
| 977 | 977 | function wpinv_tool_merge_fix_taxes() { |
| 978 | 978 | global $wpdb; |
| 979 | 979 | |
| 980 | 980 | $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
| 981 | - $items = $wpdb->get_results( $sql ); |
|
| 981 | + $items = $wpdb->get_results($sql); |
|
| 982 | 982 | |
| 983 | - if ( !empty( $items ) ) { |
|
| 984 | - foreach ( $items as $item ) { |
|
| 985 | - if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
| 986 | - update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
| 983 | + if (!empty($items)) { |
|
| 984 | + foreach ($items as $item) { |
|
| 985 | + if (get_post_meta($item->ID, '_wpinv_vat_class', true) == '_exempt') { |
|
| 986 | + update_post_meta($item->ID, '_wpinv_vat_class', '_standard'); |
|
| 987 | 987 | } |
| 988 | 988 | } |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | $sql = "SELECT `p`.`ID`, gdi.id AS gdp_id FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NOT NULL AND p.post_status NOT IN( 'publish', 'complete', 'processing', 'renewal' ) ORDER BY `gdi`.`id` ASC"; |
| 992 | - $items = $wpdb->get_results( $sql ); |
|
| 992 | + $items = $wpdb->get_results($sql); |
|
| 993 | 993 | |
| 994 | - if ( !empty( $items ) ) { |
|
| 994 | + if (!empty($items)) { |
|
| 995 | 995 | $success = false; |
| 996 | - $message = __( 'Taxes fixed for non-paid merged GD invoices.', 'invoicing' ); |
|
| 996 | + $message = __('Taxes fixed for non-paid merged GD invoices.', 'invoicing'); |
|
| 997 | 997 | |
| 998 | 998 | global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
| 999 | 999 | |
| 1000 | - foreach ( $items as $item ) { |
|
| 1000 | + foreach ($items as $item) { |
|
| 1001 | 1001 | $wpi_tax_rates = NULL; |
| 1002 | 1002 | $data = wpinv_get_invoice($item->ID); |
| 1003 | 1003 | |
| 1004 | - if ( empty( $data ) ) { |
|
| 1004 | + if (empty($data)) { |
|
| 1005 | 1005 | continue; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
@@ -1009,51 +1009,51 @@ discard block |
||
| 1009 | 1009 | |
| 1010 | 1010 | $data_session = array(); |
| 1011 | 1011 | $data_session['invoice_id'] = $data->ID; |
| 1012 | - $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
| 1012 | + $data_session['cart_discounts'] = $data->get_discounts(true); |
|
| 1013 | 1013 | |
| 1014 | - wpinv_set_checkout_session( $data_session ); |
|
| 1014 | + wpinv_set_checkout_session($data_session); |
|
| 1015 | 1015 | |
| 1016 | 1016 | $wpi_userID = (int)$data->get_user_id(); |
| 1017 | 1017 | $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
| 1018 | 1018 | |
| 1019 | - $data->country = sanitize_text_field( $_POST['country'] ); |
|
| 1020 | - $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 1019 | + $data->country = sanitize_text_field($_POST['country']); |
|
| 1020 | + $data->set('country', sanitize_text_field($_POST['country'])); |
|
| 1021 | 1021 | |
| 1022 | 1022 | $wpinv_ip_address_country = $data->country; |
| 1023 | 1023 | |
| 1024 | 1024 | $data->recalculate_totals(true); |
| 1025 | 1025 | |
| 1026 | - wpinv_set_checkout_session( $checkout_session ); |
|
| 1026 | + wpinv_set_checkout_session($checkout_session); |
|
| 1027 | 1027 | |
| 1028 | 1028 | $update_data = array(); |
| 1029 | 1029 | $update_data['tax_amount'] = $data->get_tax(); |
| 1030 | 1030 | $update_data['paied_amount'] = $data->get_total(); |
| 1031 | 1031 | $update_data['invoice_id'] = $data->ID; |
| 1032 | 1032 | |
| 1033 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
| 1033 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $item->gdp_id)); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | } else { |
| 1036 | 1036 | $success = false; |
| 1037 | - $message = __( 'No invoices found to fix taxes!', 'invoicing' ); |
|
| 1037 | + $message = __('No invoices found to fix taxes!', 'invoicing'); |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | $response = array(); |
| 1041 | 1041 | $response['success'] = $success; |
| 1042 | 1042 | $response['data']['message'] = $message; |
| 1043 | - wp_send_json( $response ); |
|
| 1043 | + wp_send_json($response); |
|
| 1044 | 1044 | } |
| 1045 | -add_action( 'wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes' ); |
|
| 1046 | -remove_action( 'geodir_before_detail_fields' , 'geodir_build_coupon', 2 ); |
|
| 1045 | +add_action('wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes'); |
|
| 1046 | +remove_action('geodir_before_detail_fields', 'geodir_build_coupon', 2); |
|
| 1047 | 1047 | |
| 1048 | -function wpinv_wpi_to_gdp_handle_subscription_cancel( $invoice_id, $invoice ) { |
|
| 1049 | - if ( wpinv_pm_active() && !empty( $invoice ) && $invoice->is_recurring() ) { |
|
| 1050 | - if ( $invoice->is_renewal() ) { |
|
| 1048 | +function wpinv_wpi_to_gdp_handle_subscription_cancel($invoice_id, $invoice) { |
|
| 1049 | + if (wpinv_pm_active() && !empty($invoice) && $invoice->is_recurring()) { |
|
| 1050 | + if ($invoice->is_renewal()) { |
|
| 1051 | 1051 | $invoice = $invoice->get_parent_payment(); |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - if ( !empty( $invoice ) ) { |
|
| 1055 | - wpinv_wpi_to_gdp_update_status( $invoice->ID, 'cancelled', $invoice->get_status() ); |
|
| 1054 | + if (!empty($invoice)) { |
|
| 1055 | + wpinv_wpi_to_gdp_update_status($invoice->ID, 'cancelled', $invoice->get_status()); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | } |
| 1058 | 1058 | } |
| 1059 | -add_action( 'wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2 ); |
|
| 1060 | 1059 | \ No newline at end of file |
| 1060 | +add_action('wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2); |
|
| 1061 | 1061 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | 'wpinv_receipt' => __CLASS__ . '::receipt', |
| 15 | 15 | ); |
| 16 | 16 | |
| 17 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
| 18 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
| 17 | + foreach ($shortcodes as $shortcode => $function) { |
|
| 18 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
| 21 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public static function shortcode_wrapper( |
@@ -32,24 +32,24 @@ discard block |
||
| 32 | 32 | ) { |
| 33 | 33 | ob_start(); |
| 34 | 34 | |
| 35 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
| 36 | - call_user_func( $function, $atts ); |
|
| 37 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
| 35 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
| 36 | + call_user_func($function, $atts); |
|
| 37 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
| 38 | 38 | |
| 39 | 39 | return ob_get_clean(); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public static function checkout( $atts = array(), $content = null ) { |
|
| 43 | - return wpinv_checkout_form( $atts, $content ); |
|
| 42 | + public static function checkout($atts = array(), $content = null) { |
|
| 43 | + return wpinv_checkout_form($atts, $content); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public static function messages( $atts, $content = null ) { |
|
| 46 | + public static function messages($atts, $content = null) { |
|
| 47 | 47 | ob_start(); |
| 48 | 48 | wpinv_print_errors(); |
| 49 | 49 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public static function history( $atts, $content = null ) { |
|
| 52 | + public static function history($atts, $content = null) { |
|
| 53 | 53 | ob_start(); |
| 54 | 54 | |
| 55 | 55 | wpinv_user_invoices(); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | return ob_get_clean(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public static function receipt( $atts, $content = null ) { |
|
| 61 | - return wpinv_payment_receipt( $atts, $content ); |
|
| 60 | + public static function receipt($atts, $content = null) { |
|
| 61 | + return wpinv_payment_receipt($atts, $content); |
|
| 62 | 62 | } |
| 63 | 63 | } |
@@ -1,34 +1,34 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Billing_Details { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $user_ID; |
| 10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 11 | + $invoice = new WPInv_Invoice($post_id); |
|
| 12 | 12 | ?> |
| 13 | 13 | <div class="gdmbx2-wrap form-table"> |
| 14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
| 15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
| 16 | 16 | <div class="gdmbx-th"> |
| 17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
| 17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
| 18 | 18 | </div> |
| 19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
| 20 | - <?php wpinv_dropdown_users( array( |
|
| 20 | + <?php wpinv_dropdown_users(array( |
|
| 21 | 21 | 'name' => 'post_author_override', |
| 22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
| 23 | 23 | 'include_selected' => true, |
| 24 | 24 | 'show' => 'user_email', |
| 25 | 25 | 'orderby' => 'user_email', |
| 26 | 26 | 'class' => 'gdmbx2-text-large' |
| 27 | - ) ); ?> |
|
| 27 | + )); ?> |
|
| 28 | 28 | </div> |
| 29 | 29 | </div> |
| 30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
| 31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
| 31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
| 32 | 32 | </div> |
| 33 | 33 | <div class="gdmbx-td"> |
| 34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
| 39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
| 39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
| 40 | 40 | </div> |
| 41 | 41 | <div class="gdmbx-td"> |
| 42 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
| 43 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
| 44 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
| 42 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
| 43 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
| 44 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
| 45 | 45 | </div> |
| 46 | 46 | </div> |
| 47 | 47 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
| 48 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 48 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 49 | 49 | <div class="gdmbx-td"> |
| 50 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" required="required" /> |
|
| 50 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" required="required" /> |
|
| 51 | 51 | </div> |
| 52 | 52 | </div> |
| 53 | 53 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
| 54 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
| 54 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
| 55 | 55 | <div class="gdmbx-td"> |
| 56 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
| 56 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
| 57 | 57 | </div> |
| 58 | 58 | </div> |
| 59 | 59 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
| 60 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
| 60 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
| 61 | 61 | <div class="gdmbx-td"> |
| 62 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
| 62 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
| 63 | 63 | </div> |
| 64 | 64 | </div> |
| 65 | 65 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
| 66 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
| 66 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
| 67 | 67 | <div class="gdmbx-td"> |
| 68 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
| 68 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
| 69 | 69 | </div> |
| 70 | 70 | </div> |
| 71 | 71 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
| 72 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 72 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 73 | 73 | <div class="gdmbx-td"> |
| 74 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" required="required" /> |
|
| 74 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" required="required" /> |
|
| 75 | 75 | </div> |
| 76 | 76 | </div> |
| 77 | 77 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
| 78 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 78 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 79 | 79 | <div class="gdmbx-td"> |
| 80 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" required="required" /> |
|
| 80 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" required="required" /> |
|
| 81 | 81 | </div> |
| 82 | 82 | </div> |
| 83 | 83 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
| 84 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="required">*</span> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 84 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="required">*</span> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 85 | 85 | <div class="gdmbx-td"> |
| 86 | 86 | <?php |
| 87 | - echo wpinv_html_select( array( |
|
| 88 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
| 87 | + echo wpinv_html_select(array( |
|
| 88 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
| 89 | 89 | 'name' => 'wpinv_country', |
| 90 | 90 | 'id' => 'wpinv_country', |
| 91 | 91 | 'selected' => $invoice->country, |
@@ -93,20 +93,20 @@ discard block |
||
| 93 | 93 | 'show_option_none' => false, |
| 94 | 94 | 'class' => 'gdmbx2-text-large', |
| 95 | 95 | 'chosen' => false, |
| 96 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 96 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 97 | 97 | 'required' => true, |
| 98 | - ) ); |
|
| 98 | + )); |
|
| 99 | 99 | ?> |
| 100 | 100 | </div> |
| 101 | 101 | </div> |
| 102 | 102 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
| 103 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?> <span class="required">*</span></label></div> |
|
| 103 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
| 104 | 104 | <div class="gdmbx-td"> |
| 105 | 105 | <?php |
| 106 | - $states = wpinv_get_country_states( $invoice->country ); |
|
| 107 | - if( !empty( $states ) ) { |
|
| 108 | - echo wpinv_html_select( array( |
|
| 109 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
| 106 | + $states = wpinv_get_country_states($invoice->country); |
|
| 107 | + if (!empty($states)) { |
|
| 108 | + echo wpinv_html_select(array( |
|
| 109 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
| 110 | 110 | 'name' => 'wpinv_state', |
| 111 | 111 | 'id' => 'wpinv_state', |
| 112 | 112 | 'selected' => $invoice->state, |
@@ -114,44 +114,44 @@ discard block |
||
| 114 | 114 | 'show_option_none' => false, |
| 115 | 115 | 'class' => 'gdmbx2-text-large', |
| 116 | 116 | 'chosen' => false, |
| 117 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 117 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 118 | 118 | 'required' => true, |
| 119 | - ) ); |
|
| 119 | + )); |
|
| 120 | 120 | } else { |
| 121 | - echo wpinv_html_text( array( |
|
| 121 | + echo wpinv_html_text(array( |
|
| 122 | 122 | 'name' => 'wpinv_state', |
| 123 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
| 123 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
| 124 | 124 | 'id' => 'wpinv_state', |
| 125 | 125 | 'class' => 'gdmbx2-text-large', |
| 126 | 126 | 'required' => true, |
| 127 | - ) ); |
|
| 127 | + )); |
|
| 128 | 128 | } |
| 129 | 129 | ?> |
| 130 | 130 | </div> |
| 131 | 131 | </div> |
| 132 | 132 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
| 133 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
| 133 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
| 134 | 134 | <div class="gdmbx-td"> |
| 135 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
| 135 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
| 136 | 136 | </div> |
| 137 | 137 | </div> |
| 138 | 138 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
| 139 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?> <?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="required">*</span>'; } ?></label></div> |
|
| 139 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?> <?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="required">*</span>'; } ?></label></div> |
|
| 140 | 140 | <div class="gdmbx-td"> |
| 141 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" <?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo 'required="required"'; } ?> /> |
|
| 141 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" <?php if (wpinv_get_option('phone_mandatory')) { echo 'required="required"'; } ?> /> |
|
| 142 | 142 | </div> |
| 143 | 143 | </div> |
| 144 | 144 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
| 145 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
| 146 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 145 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
| 146 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 147 | 147 | <?php } ?></label></div> |
| 148 | 148 | <div class="gdmbx-td"> |
| 149 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
| 149 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
| 150 | 150 | </div> |
| 151 | 151 | </div> |
| 152 | 152 | </div> |
| 153 | 153 | </div> |
| 154 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
| 154 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
| 155 | 155 | <?php |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -1,39 +1,39 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class WPInv_Meta_Box_Notes { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $post; |
| 10 | 10 | |
| 11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
| 11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
| 12 | 12 | |
| 13 | 13 | echo '<ul class="invoice_notes">'; |
| 14 | 14 | |
| 15 | - if ( $notes ) { |
|
| 16 | - foreach( $notes as $note ) { |
|
| 17 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 15 | + if ($notes) { |
|
| 16 | + foreach ($notes as $note) { |
|
| 17 | + wpinv_get_invoice_note_line_item($note); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | } else { |
| 21 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
| 21 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | echo '</ul>'; |
| 25 | 25 | ?> |
| 26 | 26 | <div class="add_note"> |
| 27 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
| 27 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
| 28 | 28 | <p> |
| 29 | 29 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
| 30 | 30 | </p> |
| 31 | 31 | <p> |
| 32 | 32 | <select name="invoice_note_type" id="invoice_note_type"> |
| 33 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
| 34 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
| 33 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
| 34 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
| 35 | 35 | </select> |
| 36 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
| 36 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
| 37 | 37 | </p> |
| 38 | 38 | </div> |
| 39 | 39 | <?php |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -register_activation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_activation' ); |
|
| 3 | -register_deactivation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation' ); |
|
| 2 | +register_activation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_activation'); |
|
| 3 | +register_deactivation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation'); |
|
| 4 | 4 | |
| 5 | -function wpinv_plugin_activation( $network_wide = false ) { |
|
| 6 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
| 7 | - wpinv_install( $network_wide ); |
|
| 5 | +function wpinv_plugin_activation($network_wide = false) { |
|
| 6 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
| 7 | + wpinv_install($network_wide); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | function wpinv_plugin_deactivation() { |
| 11 | 11 | // plugin deactivation stuff |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_install( $network_wide = false ) { |
|
| 14 | +function wpinv_install($network_wide = false) { |
|
| 15 | 15 | global $wpdb; |
| 16 | 16 | |
| 17 | - if ( is_multisite() && $network_wide ) { |
|
| 18 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
| 19 | - switch_to_blog( $blog_id ); |
|
| 17 | + if (is_multisite() && $network_wide) { |
|
| 18 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
| 19 | + switch_to_blog($blog_id); |
|
| 20 | 20 | wpinv_run_install(); |
| 21 | 21 | restore_current_blog(); |
| 22 | 22 | } |
@@ -32,75 +32,75 @@ discard block |
||
| 32 | 32 | wpinv_register_post_types(); |
| 33 | 33 | |
| 34 | 34 | // Clear the permalinks |
| 35 | - flush_rewrite_rules( false ); |
|
| 35 | + flush_rewrite_rules(false); |
|
| 36 | 36 | |
| 37 | 37 | // Add Upgraded From Option |
| 38 | - $current_version = get_option( 'wpinv_version' ); |
|
| 39 | - if ( $current_version ) { |
|
| 40 | - update_option( 'wpinv_version_upgraded_from', $current_version ); |
|
| 38 | + $current_version = get_option('wpinv_version'); |
|
| 39 | + if ($current_version) { |
|
| 40 | + update_option('wpinv_version_upgraded_from', $current_version); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Pull options from WP, not GD Invoice's global |
| 44 | - $current_options = get_option( 'wpinv_settings', array() ); |
|
| 44 | + $current_options = get_option('wpinv_settings', array()); |
|
| 45 | 45 | |
| 46 | 46 | // Setup some default options |
| 47 | 47 | $options = wpinv_create_pages(); |
| 48 | 48 | |
| 49 | 49 | // Populate some default values |
| 50 | - foreach( wpinv_get_registered_settings() as $tab => $sections ) { |
|
| 51 | - foreach( $sections as $section => $settings) { |
|
| 50 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
| 51 | + foreach ($sections as $section => $settings) { |
|
| 52 | 52 | // Check for backwards compatibility |
| 53 | - $tab_sections = wpinv_get_settings_tab_sections( $tab ); |
|
| 54 | - if( ! is_array( $tab_sections ) || ! array_key_exists( $section, $tab_sections ) ) { |
|
| 53 | + $tab_sections = wpinv_get_settings_tab_sections($tab); |
|
| 54 | + if (!is_array($tab_sections) || !array_key_exists($section, $tab_sections)) { |
|
| 55 | 55 | $section = 'main'; |
| 56 | 56 | $settings = $sections; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - foreach ( $settings as $option ) { |
|
| 60 | - if ( !empty( $option['id'] ) && !isset( $wpinv_options[ $option['id'] ] ) ) { |
|
| 61 | - if ( 'checkbox' == $option['type'] && !empty( $option['std'] ) ) { |
|
| 62 | - $options[ $option['id'] ] = '1'; |
|
| 63 | - } else if ( !empty( $option['std'] ) ) { |
|
| 64 | - $options[ $option['id'] ] = $option['std']; |
|
| 59 | + foreach ($settings as $option) { |
|
| 60 | + if (!empty($option['id']) && !isset($wpinv_options[$option['id']])) { |
|
| 61 | + if ('checkbox' == $option['type'] && !empty($option['std'])) { |
|
| 62 | + $options[$option['id']] = '1'; |
|
| 63 | + } else if (!empty($option['std'])) { |
|
| 64 | + $options[$option['id']] = $option['std']; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $merged_options = array_merge( $wpinv_options, $options ); |
|
| 71 | + $merged_options = array_merge($wpinv_options, $options); |
|
| 72 | 72 | $wpinv_options = $merged_options; |
| 73 | 73 | |
| 74 | - update_option( 'wpinv_settings', $merged_options ); |
|
| 75 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
| 74 | + update_option('wpinv_settings', $merged_options); |
|
| 75 | + update_option('wpinv_version', WPINV_VERSION); |
|
| 76 | 76 | |
| 77 | 77 | // Check for PHP Session support, and enable if available |
| 78 | 78 | $wpi_session->use_php_sessions(); |
| 79 | 79 | |
| 80 | 80 | // Add a temporary option to note that GD Invoice pages have been created |
| 81 | - set_transient( '_wpinv_installed', $merged_options, 30 ); |
|
| 81 | + set_transient('_wpinv_installed', $merged_options, 30); |
|
| 82 | 82 | |
| 83 | 83 | // Bail if activating from network, or bulk |
| 84 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 84 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 85 | 85 | return; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Add the transient to redirect |
| 89 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
| 89 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * When a new Blog is created in multisite, see if Invoicing is network activated, and run the installer. |
| 94 | 94 | * |
| 95 | 95 | */ |
| 96 | -function wpinv_new_blog_created( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 97 | - if ( is_plugin_active_for_network( plugin_basename( WPINV_PLUGIN_FILE ) ) ) { |
|
| 98 | - switch_to_blog( $blog_id ); |
|
| 96 | +function wpinv_new_blog_created($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 97 | + if (is_plugin_active_for_network(plugin_basename(WPINV_PLUGIN_FILE))) { |
|
| 98 | + switch_to_blog($blog_id); |
|
| 99 | 99 | wpinv_run_install(); |
| 100 | 100 | restore_current_blog(); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | -add_action( 'wpmu_new_blog', 'wpinv_new_blog_created', 10, 6 ); |
|
| 103 | +add_action('wpmu_new_blog', 'wpinv_new_blog_created', 10, 6); |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * Post-installation. |
@@ -108,23 +108,23 @@ discard block |
||
| 108 | 108 | * Runs just after plugin installation and exposes the wpinv_after_install hook. |
| 109 | 109 | */ |
| 110 | 110 | function wpinv_after_install() { |
| 111 | - if ( ! is_admin() ) { |
|
| 111 | + if (!is_admin()) { |
|
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $wpinv_options = get_transient( '_wpinv_installed' ); |
|
| 116 | - $wpinv_table_check = get_option( '_wpinv_table_check', false ); |
|
| 115 | + $wpinv_options = get_transient('_wpinv_installed'); |
|
| 116 | + $wpinv_table_check = get_option('_wpinv_table_check', false); |
|
| 117 | 117 | |
| 118 | - if ( false === $wpinv_table_check || current_time( 'timestamp' ) > $wpinv_table_check ) { |
|
| 119 | - update_option( '_wpinv_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
| 118 | + if (false === $wpinv_table_check || current_time('timestamp') > $wpinv_table_check) { |
|
| 119 | + update_option('_wpinv_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ( false !== $wpinv_options ) { |
|
| 122 | + if (false !== $wpinv_options) { |
|
| 123 | 123 | // Delete the transient |
| 124 | - delete_transient( '_wpinv_installed' ); |
|
| 124 | + delete_transient('_wpinv_installed'); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | -add_action( 'admin_init', 'wpinv_after_install' ); |
|
| 127 | +add_action('admin_init', 'wpinv_after_install'); |
|
| 128 | 128 | |
| 129 | 129 | function wpinv_create_pages() { |
| 130 | 130 | global $wpinv_options; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $options = array(); |
| 133 | 133 | |
| 134 | 134 | // Checks if the purchase page option exists |
| 135 | - if ( ! array_key_exists( 'checkout_page', $wpinv_options ) ) { |
|
| 135 | + if (!array_key_exists('checkout_page', $wpinv_options)) { |
|
| 136 | 136 | // Checkout Page |
| 137 | 137 | $checkout = wp_insert_post( |
| 138 | 138 | array( |
| 139 | - 'post_title' => __( 'Checkout', 'invoicing' ), |
|
| 139 | + 'post_title' => __('Checkout', 'invoicing'), |
|
| 140 | 140 | 'post_content' => '[wpinv_checkout]', |
| 141 | 141 | 'post_status' => 'publish', |
| 142 | 142 | 'post_author' => 1, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | // Invoice History (History) Page |
| 151 | 151 | $history = wp_insert_post( |
| 152 | 152 | array( |
| 153 | - 'post_title' => __( 'Invoice History', 'invoicing' ), |
|
| 153 | + 'post_title' => __('Invoice History', 'invoicing'), |
|
| 154 | 154 | 'post_content' => '[wpinv_history]', |
| 155 | 155 | 'post_status' => 'publish', |
| 156 | 156 | 'post_author' => 1, |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | // Payment Confirmation (Success) Page |
| 165 | 165 | $success = wp_insert_post( |
| 166 | 166 | array( |
| 167 | - 'post_title' => __( 'Payment Confirmation', 'invoicing' ), |
|
| 168 | - 'post_content' => __( '[wpinv_receipt]', 'invoicing' ), |
|
| 167 | + 'post_title' => __('Payment Confirmation', 'invoicing'), |
|
| 168 | + 'post_content' => __('[wpinv_receipt]', 'invoicing'), |
|
| 169 | 169 | 'post_status' => 'publish', |
| 170 | 170 | 'post_author' => 1, |
| 171 | 171 | 'post_parent' => $checkout, |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | // Failed Payment Page |
| 179 | 179 | $failed = wp_insert_post( |
| 180 | 180 | array( |
| 181 | - 'post_title' => __( 'Transaction Failed', 'invoicing' ), |
|
| 182 | - 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 181 | + 'post_title' => __('Transaction Failed', 'invoicing'), |
|
| 182 | + 'post_content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
| 183 | 183 | 'post_status' => 'publish', |
| 184 | 184 | 'post_author' => 1, |
| 185 | 185 | 'post_type' => 'page', |
@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
| 7 | +function wpinv_get_option($key = '', $default = false) { |
|
| 8 | 8 | global $wpinv_options; |
| 9 | 9 | |
| 10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
| 11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
| 10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
| 11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
| 12 | 12 | |
| 13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
| 13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
| 16 | +function wpinv_update_option($key = '', $value = false) { |
|
| 17 | 17 | // If no key, exit |
| 18 | - if ( empty( $key ) ) { |
|
| 18 | + if (empty($key)) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if ( empty( $value ) ) { |
|
| 23 | - $remove_option = wpinv_delete_option( $key ); |
|
| 22 | + if (empty($value)) { |
|
| 23 | + $remove_option = wpinv_delete_option($key); |
|
| 24 | 24 | return $remove_option; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // First let's grab the current settings |
| 28 | - $options = get_option( 'wpinv_settings' ); |
|
| 28 | + $options = get_option('wpinv_settings'); |
|
| 29 | 29 | |
| 30 | 30 | // Let's let devs alter that value coming in |
| 31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
| 31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
| 32 | 32 | |
| 33 | 33 | // Next let's try to update the value |
| 34 | - $options[ $key ] = $value; |
|
| 35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 34 | + $options[$key] = $value; |
|
| 35 | + $did_update = update_option('wpinv_settings', $options); |
|
| 36 | 36 | |
| 37 | 37 | // If it updated, let's update the global variable |
| 38 | - if ( $did_update ) { |
|
| 38 | + if ($did_update) { |
|
| 39 | 39 | global $wpinv_options; |
| 40 | - $wpinv_options[ $key ] = $value; |
|
| 40 | + $wpinv_options[$key] = $value; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return $did_update; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -function wpinv_delete_option( $key = '' ) { |
|
| 46 | +function wpinv_delete_option($key = '') { |
|
| 47 | 47 | // If no key, exit |
| 48 | - if ( empty( $key ) ) { |
|
| 48 | + if (empty($key)) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // First let's grab the current settings |
| 53 | - $options = get_option( 'wpinv_settings' ); |
|
| 53 | + $options = get_option('wpinv_settings'); |
|
| 54 | 54 | |
| 55 | 55 | // Next let's try to update the value |
| 56 | - if( isset( $options[ $key ] ) ) { |
|
| 57 | - unset( $options[ $key ] ); |
|
| 56 | + if (isset($options[$key])) { |
|
| 57 | + unset($options[$key]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 60 | + $did_update = update_option('wpinv_settings', $options); |
|
| 61 | 61 | |
| 62 | 62 | // If it updated, let's update the global variable |
| 63 | - if ( $did_update ){ |
|
| 63 | + if ($did_update) { |
|
| 64 | 64 | global $wpinv_options; |
| 65 | 65 | $wpinv_options = $options; |
| 66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function wpinv_get_settings() { |
| 72 | - $settings = get_option( 'wpinv_settings' ); |
|
| 72 | + $settings = get_option('wpinv_settings'); |
|
| 73 | 73 | |
| 74 | - if ( empty( $settings ) ) { |
|
| 74 | + if (empty($settings)) { |
|
| 75 | 75 | // Update old settings with new single option |
| 76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
| 77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
| 78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
| 79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
| 80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
| 81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
| 76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
| 77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
| 78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
| 79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
| 80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
| 81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
| 82 | 82 | |
| 83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
| 83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
| 84 | 84 | |
| 85 | - update_option( 'wpinv_settings', $settings ); |
|
| 85 | + update_option('wpinv_settings', $settings); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
| 88 | + return apply_filters('wpinv_get_settings', $settings); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function wpinv_register_settings() { |
| 92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
| 93 | - add_option( 'wpinv_settings' ); |
|
| 92 | + if (false == get_option('wpinv_settings')) { |
|
| 93 | + add_option('wpinv_settings'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $register_settings = wpinv_get_registered_settings(); |
| 97 | 97 | |
| 98 | - foreach ( $register_settings as $tab => $sections ) { |
|
| 99 | - foreach ( $sections as $section => $settings) { |
|
| 98 | + foreach ($register_settings as $tab => $sections) { |
|
| 99 | + foreach ($sections as $section => $settings) { |
|
| 100 | 100 | // Check for backwards compatibility |
| 101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
| 102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
| 101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
| 102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
| 103 | 103 | $section = 'main'; |
| 104 | 104 | $settings = $sections; |
| 105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
| 111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - foreach ( $settings as $option ) { |
|
| 114 | + foreach ($settings as $option) { |
|
| 115 | 115 | // For backwards compatibility |
| 116 | - if ( empty( $option['id'] ) ) { |
|
| 116 | + if (empty($option['id'])) { |
|
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
| 120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
| 121 | 121 | |
| 122 | 122 | add_settings_field( |
| 123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
| 124 | 124 | $name, |
| 125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
| 127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
| 128 | 128 | array( |
| 129 | 129 | 'section' => $section, |
| 130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
| 131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
| 132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
| 133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
| 138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
| 139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
| 140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
| 141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
| 147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
| 148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
| 131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
| 132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
| 133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
| 138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
| 139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
| 140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
| 141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
| 146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
| 147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
| 148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 150 | 150 | ) |
| 151 | 151 | ); |
| 152 | 152 | } |
@@ -154,162 +154,162 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Creates our settings in the options table |
| 157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
| 157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
| 158 | 158 | } |
| 159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
| 159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
| 160 | 160 | |
| 161 | 161 | function wpinv_get_registered_settings() { |
| 162 | - $pages = wpinv_get_pages( true ); |
|
| 162 | + $pages = wpinv_get_pages(true); |
|
| 163 | 163 | |
| 164 | 164 | $due_payment_options = array(); |
| 165 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
| 166 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
| 165 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
| 166 | + for ($i = 1; $i <= 30; $i++) { |
|
| 167 | 167 | $due_payment_options[$i] = $i; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $invoice_number_padd_options = array(); |
| 171 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
| 171 | + for ($i = 0; $i <= 20; $i++) { |
|
| 172 | 172 | $invoice_number_padd_options[$i] = $i; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $alert_wrapper_start = '<p style="color: #F00">'; |
| 176 | 176 | $alert_wrapper_close = '</p>'; |
| 177 | 177 | $wpinv_settings = array( |
| 178 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
| 178 | + 'general' => apply_filters('wpinv_settings_general', |
|
| 179 | 179 | array( |
| 180 | 180 | 'main' => array( |
| 181 | 181 | 'location_settings' => array( |
| 182 | 182 | 'id' => 'location_settings', |
| 183 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
| 183 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
| 184 | 184 | 'desc' => '', |
| 185 | 185 | 'type' => 'header', |
| 186 | 186 | ), |
| 187 | 187 | 'default_country' => array( |
| 188 | 188 | 'id' => 'default_country', |
| 189 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
| 190 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
| 189 | + 'name' => __('Default Country', 'invoicing'), |
|
| 190 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
| 191 | 191 | 'type' => 'select', |
| 192 | 192 | 'options' => wpinv_get_country_list(), |
| 193 | 193 | 'std' => 'GB', |
| 194 | 194 | 'chosen' => true, |
| 195 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
| 195 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
| 196 | 196 | ), |
| 197 | 197 | 'default_state' => array( |
| 198 | 198 | 'id' => 'default_state', |
| 199 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
| 200 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
| 199 | + 'name' => __('Default State / Province', 'invoicing'), |
|
| 200 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
| 201 | 201 | 'type' => 'country_states', |
| 202 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 202 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 203 | 203 | ), |
| 204 | 204 | 'store_name' => array( |
| 205 | 205 | 'id' => 'store_name', |
| 206 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
| 207 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
| 206 | + 'name' => __('Store Name', 'invoicing'), |
|
| 207 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
| 208 | 208 | 'std' => get_option('blogname'), |
| 209 | 209 | 'type' => 'text', |
| 210 | 210 | ), |
| 211 | 211 | 'logo' => array( |
| 212 | 212 | 'id' => 'logo', |
| 213 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
| 214 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
| 213 | + 'name' => __('Logo URL', 'invoicing'), |
|
| 214 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
| 215 | 215 | 'type' => 'text', |
| 216 | 216 | ), |
| 217 | 217 | 'store_address' => array( |
| 218 | 218 | 'id' => 'store_address', |
| 219 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
| 220 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
| 219 | + 'name' => __('Store Address', 'invoicing'), |
|
| 220 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
| 221 | 221 | 'type' => 'textarea', |
| 222 | 222 | ), |
| 223 | 223 | 'page_settings' => array( |
| 224 | 224 | 'id' => 'page_settings', |
| 225 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
| 225 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
| 226 | 226 | 'desc' => '', |
| 227 | 227 | 'type' => 'header', |
| 228 | 228 | ), |
| 229 | 229 | 'checkout_page' => array( |
| 230 | 230 | 'id' => 'checkout_page', |
| 231 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
| 232 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
| 231 | + 'name' => __('Checkout Page', 'invoicing'), |
|
| 232 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
| 233 | 233 | 'type' => 'select', |
| 234 | 234 | 'options' => $pages, |
| 235 | 235 | 'chosen' => true, |
| 236 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 236 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 237 | 237 | ), |
| 238 | 238 | 'success_page' => array( |
| 239 | 239 | 'id' => 'success_page', |
| 240 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
| 241 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
| 240 | + 'name' => __('Success Page', 'invoicing'), |
|
| 241 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
| 242 | 242 | 'type' => 'select', |
| 243 | 243 | 'options' => $pages, |
| 244 | 244 | 'chosen' => true, |
| 245 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 245 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 246 | 246 | ), |
| 247 | 247 | 'failure_page' => array( |
| 248 | 248 | 'id' => 'failure_page', |
| 249 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
| 250 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ), |
|
| 249 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
| 250 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'), |
|
| 251 | 251 | 'type' => 'select', |
| 252 | 252 | 'options' => $pages, |
| 253 | 253 | 'chosen' => true, |
| 254 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 254 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 255 | 255 | ), |
| 256 | 256 | 'invoice_history_page' => array( |
| 257 | 257 | 'id' => 'invoice_history_page', |
| 258 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
| 259 | - 'desc' => __( 'This page shows a invoice history for the current user', 'invoicing' ), |
|
| 258 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
| 259 | + 'desc' => __('This page shows a invoice history for the current user', 'invoicing'), |
|
| 260 | 260 | 'type' => 'select', |
| 261 | 261 | 'options' => $pages, |
| 262 | 262 | 'chosen' => true, |
| 263 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 263 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 264 | 264 | ) |
| 265 | 265 | ), |
| 266 | 266 | 'currency_section' => array( |
| 267 | 267 | 'currency_settings' => array( |
| 268 | 268 | 'id' => 'currency_settings', |
| 269 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
| 269 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
| 270 | 270 | 'desc' => '', |
| 271 | 271 | 'type' => 'header', |
| 272 | 272 | ), |
| 273 | 273 | 'currency' => array( |
| 274 | 274 | 'id' => 'currency', |
| 275 | - 'name' => __( 'Currency', 'invoicing' ), |
|
| 276 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
| 275 | + 'name' => __('Currency', 'invoicing'), |
|
| 276 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
| 277 | 277 | 'type' => 'select', |
| 278 | 278 | 'options' => wpinv_get_currencies(), |
| 279 | 279 | 'chosen' => true, |
| 280 | 280 | ), |
| 281 | 281 | 'currency_position' => array( |
| 282 | 282 | 'id' => 'currency_position', |
| 283 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
| 284 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
| 283 | + 'name' => __('Currency Position', 'invoicing'), |
|
| 284 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
| 285 | 285 | 'type' => 'select', |
| 286 | 286 | 'options' => array( |
| 287 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . wpinv_currency_symbol() . '99.99)', |
|
| 288 | - 'right' => __( 'Right', 'invoicing' ) . ' (99.99' . wpinv_currency_symbol() . ')', |
|
| 289 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . wpinv_currency_symbol() . ' 99.99)', |
|
| 290 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (99.99 ' . wpinv_currency_symbol() . ')' |
|
| 287 | + 'left' => __('Left', 'invoicing') . ' (' . wpinv_currency_symbol() . '99.99)', |
|
| 288 | + 'right' => __('Right', 'invoicing') . ' (99.99' . wpinv_currency_symbol() . ')', |
|
| 289 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . wpinv_currency_symbol() . ' 99.99)', |
|
| 290 | + 'right_space' => __('Right with space', 'invoicing') . ' (99.99 ' . wpinv_currency_symbol() . ')' |
|
| 291 | 291 | ) |
| 292 | 292 | ), |
| 293 | 293 | 'thousands_separator' => array( |
| 294 | 294 | 'id' => 'thousands_separator', |
| 295 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
| 296 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
| 295 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
| 296 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
| 297 | 297 | 'type' => 'text', |
| 298 | 298 | 'size' => 'small', |
| 299 | 299 | 'std' => ',', |
| 300 | 300 | ), |
| 301 | 301 | 'decimal_separator' => array( |
| 302 | 302 | 'id' => 'decimal_separator', |
| 303 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
| 304 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
| 303 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
| 304 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
| 305 | 305 | 'type' => 'text', |
| 306 | 306 | 'size' => 'small', |
| 307 | 307 | 'std' => '.', |
| 308 | 308 | ), |
| 309 | 309 | 'decimals' => array( |
| 310 | 310 | 'id' => 'decimals', |
| 311 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
| 312 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
| 311 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
| 312 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
| 313 | 313 | 'type' => 'number', |
| 314 | 314 | 'size' => 'small', |
| 315 | 315 | 'std' => '2', |
@@ -321,29 +321,29 @@ discard block |
||
| 321 | 321 | 'labels' => array( |
| 322 | 322 | 'labels' => array( |
| 323 | 323 | 'id' => 'labels_settings', |
| 324 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
| 324 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
| 325 | 325 | 'desc' => '', |
| 326 | 326 | 'type' => 'header', |
| 327 | 327 | ), |
| 328 | 328 | 'vat_name' => array( |
| 329 | 329 | 'id' => 'vat_name', |
| 330 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
| 331 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
| 330 | + 'name' => __('VAT Name', 'invoicing'), |
|
| 331 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
| 332 | 332 | 'type' => 'text', |
| 333 | 333 | 'size' => 'regular', |
| 334 | 334 | 'std' => 'VAT' |
| 335 | 335 | ), |
| 336 | 336 | 'vat_invoice_notice_label' => array( |
| 337 | 337 | 'id' => 'vat_invoice_notice_label', |
| 338 | - 'name' => __( 'Invoice notice label', 'invoicing' ), |
|
| 339 | - 'desc' => __( 'Use this to add a invoice notice section (label) to your invoices', 'invoicing' ), |
|
| 338 | + 'name' => __('Invoice notice label', 'invoicing'), |
|
| 339 | + 'desc' => __('Use this to add a invoice notice section (label) to your invoices', 'invoicing'), |
|
| 340 | 340 | 'type' => 'text', |
| 341 | 341 | 'size' => 'regular', |
| 342 | 342 | ), |
| 343 | 343 | 'vat_invoice_notice' => array( |
| 344 | 344 | 'id' => 'vat_invoice_notice', |
| 345 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
| 346 | - 'desc' => __( 'Use this to add a invoice notice section (description) to your invoices', 'invoicing' ), |
|
| 345 | + 'name' => __('Invoice notice', 'invoicing'), |
|
| 346 | + 'desc' => __('Use this to add a invoice notice section (description) to your invoices', 'invoicing'), |
|
| 347 | 347 | 'type' => 'text', |
| 348 | 348 | 'size' => 'regular', |
| 349 | 349 | ) |
@@ -355,22 +355,22 @@ discard block |
||
| 355 | 355 | 'main' => array( |
| 356 | 356 | 'gateway_settings' => array( |
| 357 | 357 | 'id' => 'api_header', |
| 358 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
| 358 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
| 359 | 359 | 'desc' => '', |
| 360 | 360 | 'type' => 'header', |
| 361 | 361 | ), |
| 362 | 362 | 'gateways' => array( |
| 363 | 363 | 'id' => 'gateways', |
| 364 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 365 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
| 364 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
| 365 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
| 366 | 366 | 'type' => 'gateways', |
| 367 | 367 | 'std' => array('manual'=>1), |
| 368 | 368 | 'options' => wpinv_get_payment_gateways(), |
| 369 | 369 | ), |
| 370 | 370 | 'default_gateway' => array( |
| 371 | 371 | 'id' => 'default_gateway', |
| 372 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
| 373 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
| 372 | + 'name' => __('Default Gateway', 'invoicing'), |
|
| 373 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
| 374 | 374 | 'type' => 'gateway_select', |
| 375 | 375 | 'std' => 'manual', |
| 376 | 376 | 'options' => wpinv_get_payment_gateways(), |
@@ -384,19 +384,19 @@ discard block |
||
| 384 | 384 | 'main' => array( |
| 385 | 385 | 'tax_settings' => array( |
| 386 | 386 | 'id' => 'tax_settings', |
| 387 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
| 387 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
| 388 | 388 | 'type' => 'header', |
| 389 | 389 | ), |
| 390 | 390 | 'enable_taxes' => array( |
| 391 | 391 | 'id' => 'enable_taxes', |
| 392 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
| 393 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
| 392 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
| 393 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
| 394 | 394 | 'type' => 'checkbox', |
| 395 | 395 | ), |
| 396 | 396 | 'tax_rate' => array( |
| 397 | 397 | 'id' => 'tax_rate', |
| 398 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
| 399 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
| 398 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
| 399 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
| 400 | 400 | 'type' => 'number', |
| 401 | 401 | 'size' => 'small', |
| 402 | 402 | 'min' => '0', |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | 'rates' => array( |
| 409 | 409 | 'tax_rates' => array( |
| 410 | 410 | 'id' => 'tax_rates', |
| 411 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
| 412 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
| 411 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
| 412 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
| 413 | 413 | 'type' => 'tax_rates', |
| 414 | 414 | ), |
| 415 | 415 | ) |
@@ -421,62 +421,62 @@ discard block |
||
| 421 | 421 | 'main' => array( |
| 422 | 422 | 'email_settings_header' => array( |
| 423 | 423 | 'id' => 'email_settings_header', |
| 424 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
| 424 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
| 425 | 425 | 'type' => 'header', |
| 426 | 426 | ), |
| 427 | 427 | 'email_from_name' => array( |
| 428 | 428 | 'id' => 'email_from_name', |
| 429 | - 'name' => __( 'From Name', 'invoicing' ), |
|
| 430 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
| 431 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
| 429 | + 'name' => __('From Name', 'invoicing'), |
|
| 430 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
| 431 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
| 432 | 432 | 'type' => 'text', |
| 433 | 433 | ), |
| 434 | 434 | 'email_from' => array( |
| 435 | 435 | 'id' => 'email_from', |
| 436 | - 'name' => __( 'From Email', 'invoicing' ), |
|
| 437 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
| 438 | - 'std' => get_option( 'admin_email' ), |
|
| 436 | + 'name' => __('From Email', 'invoicing'), |
|
| 437 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
| 438 | + 'std' => get_option('admin_email'), |
|
| 439 | 439 | 'type' => 'text', |
| 440 | 440 | ), |
| 441 | 441 | 'overdue_settings_header' => array( |
| 442 | 442 | 'id' => 'overdue_settings_header', |
| 443 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
| 443 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
| 444 | 444 | 'type' => 'header', |
| 445 | 445 | ), |
| 446 | 446 | 'overdue_active' => array( |
| 447 | 447 | 'id' => 'overdue_active', |
| 448 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
| 449 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
| 448 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
| 449 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
| 450 | 450 | 'type' => 'checkbox', |
| 451 | 451 | 'std' => false, |
| 452 | 452 | ), |
| 453 | 453 | 'overdue_days' => array( |
| 454 | 454 | 'id' => 'overdue_days', |
| 455 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
| 456 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
| 455 | + 'name' => __('Default Due Date', 'invoicing'), |
|
| 456 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
| 457 | 457 | 'type' => 'select', |
| 458 | 458 | 'options' => $due_payment_options, |
| 459 | 459 | 'chosen' => true, |
| 460 | 460 | 'std' => 0, |
| 461 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 461 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 462 | 462 | ), |
| 463 | 463 | 'email_template_header' => array( |
| 464 | 464 | 'id' => 'email_template_header', |
| 465 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
| 465 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
| 466 | 466 | 'type' => 'header', |
| 467 | 467 | ), |
| 468 | 468 | 'email_header_image' => array( |
| 469 | 469 | 'id' => 'email_header_image', |
| 470 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
| 471 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
| 470 | + 'name' => __('Header Image', 'invoicing'), |
|
| 471 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
| 472 | 472 | 'std' => '', |
| 473 | 473 | 'type' => 'text', |
| 474 | 474 | ), |
| 475 | 475 | 'email_footer_text' => array( |
| 476 | 476 | 'id' => 'email_footer_text', |
| 477 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
| 478 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
| 479 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
| 477 | + 'name' => __('Footer Text', 'invoicing'), |
|
| 478 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
| 479 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
| 480 | 480 | 'type' => 'textarea', |
| 481 | 481 | 'class' => 'regular-text', |
| 482 | 482 | 'rows' => 2, |
@@ -484,29 +484,29 @@ discard block |
||
| 484 | 484 | ), |
| 485 | 485 | 'email_base_color' => array( |
| 486 | 486 | 'id' => 'email_base_color', |
| 487 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
| 488 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
| 487 | + 'name' => __('Base Color', 'invoicing'), |
|
| 488 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
| 489 | 489 | 'std' => '#557da2', |
| 490 | 490 | 'type' => 'color', |
| 491 | 491 | ), |
| 492 | 492 | 'email_background_color' => array( |
| 493 | 493 | 'id' => 'email_background_color', |
| 494 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
| 495 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
| 494 | + 'name' => __('Background Color', 'invoicing'), |
|
| 495 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
| 496 | 496 | 'std' => '#f5f5f5', |
| 497 | 497 | 'type' => 'color', |
| 498 | 498 | ), |
| 499 | 499 | 'email_body_background_color' => array( |
| 500 | 500 | 'id' => 'email_body_background_color', |
| 501 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
| 502 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
| 501 | + 'name' => __('Body Background Color', 'invoicing'), |
|
| 502 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
| 503 | 503 | 'std' => '#fdfdfd', |
| 504 | 504 | 'type' => 'color', |
| 505 | 505 | ), |
| 506 | 506 | 'email_text_color' => array( |
| 507 | 507 | 'id' => 'email_text_color', |
| 508 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
| 509 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
| 508 | + 'name' => __('Body Text Color', 'invoicing'), |
|
| 509 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
| 510 | 510 | 'std' => '#505050', |
| 511 | 511 | 'type' => 'color', |
| 512 | 512 | ), |
@@ -525,25 +525,25 @@ discard block |
||
| 525 | 525 | 'main' => array( |
| 526 | 526 | 'fields_settings' => array( |
| 527 | 527 | 'id' => 'fields_settings', |
| 528 | - 'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>', |
|
| 528 | + 'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>', |
|
| 529 | 529 | 'type' => 'header', |
| 530 | 530 | ), |
| 531 | 531 | 'phone_mandatory' => array( |
| 532 | 532 | 'id' => 'phone_mandatory', |
| 533 | - 'name' => __( 'Phone No. Mandatory?', 'invoicing' ), |
|
| 534 | - 'desc' => __( 'Tick this to make phone number mandatory in invoice address fields.', 'invoicing' ), |
|
| 533 | + 'name' => __('Phone No. Mandatory?', 'invoicing'), |
|
| 534 | + 'desc' => __('Tick this to make phone number mandatory in invoice address fields.', 'invoicing'), |
|
| 535 | 535 | 'type' => 'checkbox', |
| 536 | 536 | 'std' => true, |
| 537 | 537 | ), |
| 538 | 538 | 'invoice_number_format_settings' => array( |
| 539 | 539 | 'id' => 'invoice_number_format_settings', |
| 540 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
| 540 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
| 541 | 541 | 'type' => 'header', |
| 542 | 542 | ), |
| 543 | 543 | 'invoice_number_padd' => array( |
| 544 | 544 | 'id' => 'invoice_number_padd', |
| 545 | - 'name' => __( 'Minimum digits', 'invoicing' ), |
|
| 546 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
| 545 | + 'name' => __('Minimum digits', 'invoicing'), |
|
| 546 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
| 547 | 547 | 'type' => 'select', |
| 548 | 548 | 'options' => $invoice_number_padd_options, |
| 549 | 549 | 'std' => 5, |
@@ -551,8 +551,8 @@ discard block |
||
| 551 | 551 | ), |
| 552 | 552 | 'invoice_number_prefix' => array( |
| 553 | 553 | 'id' => 'invoice_number_prefix', |
| 554 | - 'name' => __( 'Invoice Number prefix', 'invoicing' ), |
|
| 555 | - 'desc' => __( 'A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
| 554 | + 'name' => __('Invoice Number prefix', 'invoicing'), |
|
| 555 | + 'desc' => __('A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
| 556 | 556 | 'type' => 'text', |
| 557 | 557 | 'size' => 'regular', |
| 558 | 558 | 'std' => 'WPINV-', |
@@ -560,25 +560,25 @@ discard block |
||
| 560 | 560 | ), |
| 561 | 561 | 'invoice_number_postfix' => array( |
| 562 | 562 | 'id' => 'invoice_number_postfix', |
| 563 | - 'name' => __( 'Invoice Number postfix', 'invoicing' ), |
|
| 564 | - 'desc' => __( 'A postfix to append to all invoice numbers.', 'invoicing' ), |
|
| 563 | + 'name' => __('Invoice Number postfix', 'invoicing'), |
|
| 564 | + 'desc' => __('A postfix to append to all invoice numbers.', 'invoicing'), |
|
| 565 | 565 | 'type' => 'text', |
| 566 | 566 | 'size' => 'regular', |
| 567 | 567 | 'std' => '' |
| 568 | 568 | ), |
| 569 | 569 | 'guest_checkout_settings' => array( |
| 570 | 570 | 'id' => 'guest_checkout_settings', |
| 571 | - 'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>', |
|
| 571 | + 'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>', |
|
| 572 | 572 | 'type' => 'header', |
| 573 | 573 | ), |
| 574 | 574 | 'guest_checkout' => array( |
| 575 | 575 | 'type' => 'radio', |
| 576 | 576 | 'id' => 'guest_checkout', |
| 577 | - 'name' => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ), |
|
| 578 | - 'desc' => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing' ), |
|
| 577 | + 'name' => __('Pay via Invoice Link for non logged in user', 'invoicing'), |
|
| 578 | + 'desc' => __('Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing'), |
|
| 579 | 579 | 'options' => array( |
| 580 | - 0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ), |
|
| 581 | - 1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ), |
|
| 580 | + 0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'), |
|
| 581 | + 1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'), |
|
| 582 | 582 | ), |
| 583 | 583 | 'std' => 0, |
| 584 | 584 | ), |
@@ -591,8 +591,8 @@ discard block |
||
| 591 | 591 | 'main' => array( |
| 592 | 592 | 'tool_settings' => array( |
| 593 | 593 | 'id' => 'tool_settings', |
| 594 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
| 595 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
| 594 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
| 595 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
| 596 | 596 | 'type' => 'tools', |
| 597 | 597 | ), |
| 598 | 598 | ), |
@@ -600,96 +600,96 @@ discard block |
||
| 600 | 600 | ) |
| 601 | 601 | ); |
| 602 | 602 | |
| 603 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
| 603 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 606 | +function wpinv_settings_sanitize($input = array()) { |
|
| 607 | 607 | global $wpinv_options; |
| 608 | 608 | |
| 609 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
| 609 | + if (empty($_POST['_wp_http_referer'])) { |
|
| 610 | 610 | return $input; |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
| 613 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
| 614 | 614 | |
| 615 | 615 | $settings = wpinv_get_registered_settings(); |
| 616 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 617 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 616 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 617 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 618 | 618 | |
| 619 | 619 | $input = $input ? $input : array(); |
| 620 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 621 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 620 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 621 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 622 | 622 | |
| 623 | 623 | // Loop through each setting being saved and pass it through a sanitization filter |
| 624 | - foreach ( $input as $key => $value ) { |
|
| 624 | + foreach ($input as $key => $value) { |
|
| 625 | 625 | // Get the setting type (checkbox, select, etc) |
| 626 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
| 626 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
| 627 | 627 | |
| 628 | - if ( $type ) { |
|
| 628 | + if ($type) { |
|
| 629 | 629 | // Field type specific filter |
| 630 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
| 630 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | // General filter |
| 634 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 634 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 638 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 639 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 638 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 639 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 640 | 640 | |
| 641 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 641 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 642 | 642 | |
| 643 | - if ( ! empty( $found_settings ) ) { |
|
| 644 | - foreach ( $found_settings as $key => $value ) { |
|
| 643 | + if (!empty($found_settings)) { |
|
| 644 | + foreach ($found_settings as $key => $value) { |
|
| 645 | 645 | |
| 646 | 646 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 647 | - if ( is_numeric( $key ) ) { |
|
| 647 | + if (is_numeric($key)) { |
|
| 648 | 648 | $key = $value['id']; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | - if ( empty( $input[ $key ] ) ) { |
|
| 652 | - unset( $wpinv_options[ $key ] ); |
|
| 651 | + if (empty($input[$key])) { |
|
| 652 | + unset($wpinv_options[$key]); |
|
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Merge our new settings with the existing |
| 658 | - $output = array_merge( $wpinv_options, $input ); |
|
| 658 | + $output = array_merge($wpinv_options, $input); |
|
| 659 | 659 | |
| 660 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 660 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 661 | 661 | |
| 662 | 662 | return $output; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
| 665 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
| 666 | 666 | global $wpinv_options, $wpi_session; |
| 667 | 667 | |
| 668 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 668 | + if (!current_user_can('manage_options')) { |
|
| 669 | 669 | return $input; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
| 672 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
| 673 | 673 | // Shows an admin notice about upgrading previous order numbers |
| 674 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
| 674 | + $wpi_session->set('upgrade_sequential', '1'); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | return $input; |
| 678 | 678 | } |
| 679 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
| 679 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
| 680 | 680 | |
| 681 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 682 | - if( !current_user_can( 'manage_options' ) ) { |
|
| 681 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 682 | + if (!current_user_can('manage_options')) { |
|
| 683 | 683 | return $input; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
| 686 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
| 687 | 687 | |
| 688 | 688 | $tax_rates = array(); |
| 689 | 689 | |
| 690 | - if ( !empty( $new_rates ) ) { |
|
| 691 | - foreach ( $new_rates as $rate ) { |
|
| 692 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
| 690 | + if (!empty($new_rates)) { |
|
| 691 | + foreach ($new_rates as $rate) { |
|
| 692 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
| 693 | 693 | continue; |
| 694 | 694 | } |
| 695 | 695 | |
@@ -697,36 +697,36 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 700 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 701 | 701 | |
| 702 | 702 | return $input; |
| 703 | 703 | } |
| 704 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 704 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 705 | 705 | |
| 706 | -function wpinv_sanitize_text_field( $input ) { |
|
| 707 | - return trim( $input ); |
|
| 706 | +function wpinv_sanitize_text_field($input) { |
|
| 707 | + return trim($input); |
|
| 708 | 708 | } |
| 709 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
| 709 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
| 710 | 710 | |
| 711 | 711 | function wpinv_get_settings_tabs() { |
| 712 | 712 | $tabs = array(); |
| 713 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 714 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 715 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 716 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 717 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 718 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 719 | - |
|
| 720 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 713 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 714 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 715 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 716 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 717 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 718 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 719 | + |
|
| 720 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 723 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 724 | 724 | $tabs = false; |
| 725 | 725 | $sections = wpinv_get_registered_settings_sections(); |
| 726 | 726 | |
| 727 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 728 | - $tabs = $sections[ $tab ]; |
|
| 729 | - } else if ( $tab ) { |
|
| 727 | + if ($tab && !empty($sections[$tab])) { |
|
| 728 | + $tabs = $sections[$tab]; |
|
| 729 | + } else if ($tab) { |
|
| 730 | 730 | $tabs = false; |
| 731 | 731 | } |
| 732 | 732 | |
@@ -736,135 +736,135 @@ discard block |
||
| 736 | 736 | function wpinv_get_registered_settings_sections() { |
| 737 | 737 | static $sections = false; |
| 738 | 738 | |
| 739 | - if ( false !== $sections ) { |
|
| 739 | + if (false !== $sections) { |
|
| 740 | 740 | return $sections; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | $sections = array( |
| 744 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
| 745 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 746 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 747 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 748 | - ) ), |
|
| 749 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
| 750 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 751 | - ) ), |
|
| 752 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
| 753 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 754 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 755 | - ) ), |
|
| 756 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
| 757 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 758 | - ) ), |
|
| 759 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
| 760 | - 'main' => __( 'Misc Settings', 'invoicing' ), |
|
| 761 | - ) ), |
|
| 762 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
| 763 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 764 | - ) ), |
|
| 744 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
| 745 | + 'main' => __('General Settings', 'invoicing'), |
|
| 746 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 747 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 748 | + )), |
|
| 749 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
| 750 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 751 | + )), |
|
| 752 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
| 753 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 754 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 755 | + )), |
|
| 756 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
| 757 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 758 | + )), |
|
| 759 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
| 760 | + 'main' => __('Misc Settings', 'invoicing'), |
|
| 761 | + )), |
|
| 762 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
| 763 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 764 | + )), |
|
| 765 | 765 | ); |
| 766 | 766 | |
| 767 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 767 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 768 | 768 | |
| 769 | 769 | return $sections; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
| 772 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
| 773 | 773 | $pages_options = array(); |
| 774 | 774 | |
| 775 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 776 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 775 | + if ($default_label !== NULL && $default_label !== false) { |
|
| 776 | + $pages_options = array('' => $default_label); // Blank option |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | $pages = get_pages(); |
| 780 | - if ( $pages ) { |
|
| 781 | - foreach ( $pages as $page ) { |
|
| 780 | + if ($pages) { |
|
| 781 | + foreach ($pages as $page) { |
|
| 782 | 782 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 783 | - $pages_options[ $page->ID ] = $title; |
|
| 783 | + $pages_options[$page->ID] = $title; |
|
| 784 | 784 | } |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | return $pages_options; |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | -function wpinv_header_callback( $args ) { |
|
| 791 | - if ( !empty( $args['desc'] ) ) { |
|
| 790 | +function wpinv_header_callback($args) { |
|
| 791 | + if (!empty($args['desc'])) { |
|
| 792 | 792 | echo $args['desc']; |
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | -function wpinv_hidden_callback( $args ) { |
|
| 796 | +function wpinv_hidden_callback($args) { |
|
| 797 | 797 | global $wpinv_options; |
| 798 | 798 | |
| 799 | - if ( isset( $args['set_value'] ) ) { |
|
| 799 | + if (isset($args['set_value'])) { |
|
| 800 | 800 | $value = $args['set_value']; |
| 801 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 802 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 801 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
| 802 | + $value = $wpinv_options[$args['id']]; |
|
| 803 | 803 | } else { |
| 804 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 804 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 807 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 808 | 808 | $args['readonly'] = true; |
| 809 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 809 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 810 | 810 | $name = ''; |
| 811 | 811 | } else { |
| 812 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 812 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 815 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 816 | 816 | |
| 817 | 817 | echo $html; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | -function wpinv_checkbox_callback( $args ) { |
|
| 820 | +function wpinv_checkbox_callback($args) { |
|
| 821 | 821 | global $wpinv_options; |
| 822 | 822 | |
| 823 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 823 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 824 | 824 | |
| 825 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 825 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 826 | 826 | $name = ''; |
| 827 | 827 | } else { |
| 828 | 828 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
| 829 | 829 | } |
| 830 | 830 | |
| 831 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 831 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
| 832 | 832 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
| 833 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 833 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 834 | 834 | |
| 835 | 835 | echo $html; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | -function wpinv_multicheck_callback( $args ) { |
|
| 838 | +function wpinv_multicheck_callback($args) { |
|
| 839 | 839 | global $wpinv_options; |
| 840 | 840 | |
| 841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 841 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 842 | 842 | |
| 843 | - if ( ! empty( $args['options'] ) ) { |
|
| 844 | - foreach( $args['options'] as $key => $option ): |
|
| 845 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 846 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 843 | + if (!empty($args['options'])) { |
|
| 844 | + foreach ($args['options'] as $key => $option): |
|
| 845 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 846 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
| 847 | 847 | $enabled = $sanitize_key; |
| 848 | 848 | } else { |
| 849 | 849 | $enabled = NULL; |
| 850 | 850 | } |
| 851 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 852 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 851 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
| 852 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
| 853 | 853 | endforeach; |
| 854 | 854 | echo '<p class="description">' . $args['desc'] . '</p>'; |
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | -function wpinv_payment_icons_callback( $args ) { |
|
| 858 | +function wpinv_payment_icons_callback($args) { |
|
| 859 | 859 | global $wpinv_options; |
| 860 | 860 | |
| 861 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 861 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 862 | 862 | |
| 863 | - if ( ! empty( $args['options'] ) ) { |
|
| 864 | - foreach( $args['options'] as $key => $option ) { |
|
| 865 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 863 | + if (!empty($args['options'])) { |
|
| 864 | + foreach ($args['options'] as $key => $option) { |
|
| 865 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 866 | 866 | |
| 867 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 867 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
| 868 | 868 | $enabled = $option; |
| 869 | 869 | } else { |
| 870 | 870 | $enabled = NULL; |
@@ -872,194 +872,194 @@ discard block |
||
| 872 | 872 | |
| 873 | 873 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 874 | 874 | |
| 875 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 875 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
| 876 | 876 | |
| 877 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 878 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 877 | + if (wpinv_string_is_image_url($key)) { |
|
| 878 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 879 | 879 | } else { |
| 880 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 880 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 881 | 881 | |
| 882 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 883 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 882 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 883 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 884 | 884 | } else { |
| 885 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 885 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 886 | 886 | $content_dir = WP_CONTENT_DIR; |
| 887 | 887 | |
| 888 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 888 | + if (function_exists('wp_normalize_path')) { |
|
| 889 | 889 | // Replaces backslashes with forward slashes for Windows systems |
| 890 | - $image = wp_normalize_path( $image ); |
|
| 891 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 890 | + $image = wp_normalize_path($image); |
|
| 891 | + $content_dir = wp_normalize_path($content_dir); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 894 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 897 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 898 | 898 | } |
| 899 | 899 | echo $option . '</label>'; |
| 900 | 900 | } |
| 901 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 901 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | -function wpinv_radio_callback( $args ) { |
|
| 905 | +function wpinv_radio_callback($args) { |
|
| 906 | 906 | global $wpinv_options; |
| 907 | 907 | |
| 908 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 908 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 909 | 909 | |
| 910 | - foreach ( $args['options'] as $key => $option ) : |
|
| 911 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 910 | + foreach ($args['options'] as $key => $option) : |
|
| 911 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 912 | 912 | |
| 913 | 913 | $checked = false; |
| 914 | 914 | |
| 915 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 915 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
| 916 | 916 | $checked = true; |
| 917 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 917 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
| 918 | 918 | $checked = true; |
| 919 | 919 | |
| 920 | 920 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
| 921 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 921 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
| 922 | 922 | endforeach; |
| 923 | 923 | |
| 924 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 924 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | -function wpinv_gateways_callback( $args ) { |
|
| 927 | +function wpinv_gateways_callback($args) { |
|
| 928 | 928 | global $wpinv_options; |
| 929 | 929 | |
| 930 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 930 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 931 | 931 | |
| 932 | - foreach ( $args['options'] as $key => $option ) : |
|
| 933 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 932 | + foreach ($args['options'] as $key => $option) : |
|
| 933 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 934 | 934 | |
| 935 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
| 935 | + if (isset($wpinv_options['gateways'][$key])) |
|
| 936 | 936 | $enabled = '1'; |
| 937 | 937 | else |
| 938 | 938 | $enabled = null; |
| 939 | 939 | |
| 940 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 941 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 940 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 941 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
| 942 | 942 | endforeach; |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | function wpinv_gateway_select_callback($args) { |
| 946 | 946 | global $wpinv_options; |
| 947 | 947 | |
| 948 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 948 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 949 | 949 | |
| 950 | 950 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
| 951 | 951 | |
| 952 | - foreach ( $args['options'] as $key => $option ) : |
|
| 953 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 954 | - $selected = selected( $key, $args['selected'], false ); |
|
| 952 | + foreach ($args['options'] as $key => $option) : |
|
| 953 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 954 | + $selected = selected($key, $args['selected'], false); |
|
| 955 | 955 | } else { |
| 956 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
| 956 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
| 957 | 957 | } |
| 958 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 958 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 959 | 959 | endforeach; |
| 960 | 960 | |
| 961 | 961 | echo '</select>'; |
| 962 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 962 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | -function wpinv_text_callback( $args ) { |
|
| 965 | +function wpinv_text_callback($args) { |
|
| 966 | 966 | global $wpinv_options; |
| 967 | 967 | |
| 968 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 968 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 969 | 969 | |
| 970 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 971 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 970 | + if (isset($wpinv_options[$args['id']])) { |
|
| 971 | + $value = $wpinv_options[$args['id']]; |
|
| 972 | 972 | } else { |
| 973 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 973 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 976 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 977 | 977 | $args['readonly'] = true; |
| 978 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 978 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 979 | 979 | $name = ''; |
| 980 | 980 | } else { |
| 981 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 981 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
| 985 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 986 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 987 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 985 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 986 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
| 987 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 988 | 988 | |
| 989 | 989 | echo $html; |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | -function wpinv_number_callback( $args ) { |
|
| 992 | +function wpinv_number_callback($args) { |
|
| 993 | 993 | global $wpinv_options; |
| 994 | 994 | |
| 995 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 995 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 996 | 996 | |
| 997 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 998 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 997 | + if (isset($wpinv_options[$args['id']])) { |
|
| 998 | + $value = $wpinv_options[$args['id']]; |
|
| 999 | 999 | } else { |
| 1000 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1000 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1003 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1004 | 1004 | $args['readonly'] = true; |
| 1005 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1005 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1006 | 1006 | $name = ''; |
| 1007 | 1007 | } else { |
| 1008 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1008 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1012 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1013 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1011 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
| 1012 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
| 1013 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
| 1014 | 1014 | |
| 1015 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1016 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1017 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1015 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1016 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1017 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1018 | 1018 | |
| 1019 | 1019 | echo $html; |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | -function wpinv_textarea_callback( $args ) { |
|
| 1022 | +function wpinv_textarea_callback($args) { |
|
| 1023 | 1023 | global $wpinv_options; |
| 1024 | 1024 | |
| 1025 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1025 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1026 | 1026 | |
| 1027 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1028 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1027 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1028 | + $value = $wpinv_options[$args['id']]; |
|
| 1029 | 1029 | } else { |
| 1030 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1030 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1034 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 1033 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1034 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 1035 | 1035 | |
| 1036 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1037 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1036 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1037 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1038 | 1038 | |
| 1039 | 1039 | echo $html; |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | -function wpinv_password_callback( $args ) { |
|
| 1042 | +function wpinv_password_callback($args) { |
|
| 1043 | 1043 | global $wpinv_options; |
| 1044 | 1044 | |
| 1045 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1045 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1046 | 1046 | |
| 1047 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1048 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1047 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1048 | + $value = $wpinv_options[$args['id']]; |
|
| 1049 | 1049 | } else { |
| 1050 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1050 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1054 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1055 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1053 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1054 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
| 1055 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1056 | 1056 | |
| 1057 | 1057 | echo $html; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | function wpinv_missing_callback($args) { |
| 1061 | 1061 | printf( |
| 1062 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1062 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 1063 | 1063 | '<strong>' . $args['id'] . '</strong>' |
| 1064 | 1064 | ); |
| 1065 | 1065 | } |
@@ -1067,137 +1067,137 @@ discard block |
||
| 1067 | 1067 | function wpinv_select_callback($args) { |
| 1068 | 1068 | global $wpinv_options; |
| 1069 | 1069 | |
| 1070 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1070 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1071 | 1071 | |
| 1072 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1073 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1072 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1073 | + $value = $wpinv_options[$args['id']]; |
|
| 1074 | 1074 | } else { |
| 1075 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1075 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1078 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1079 | 1079 | $value = $args['selected']; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1082 | + if (isset($args['placeholder'])) { |
|
| 1083 | 1083 | $placeholder = $args['placeholder']; |
| 1084 | 1084 | } else { |
| 1085 | 1085 | $placeholder = ''; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | - if ( isset( $args['chosen'] ) ) { |
|
| 1088 | + if (isset($args['chosen'])) { |
|
| 1089 | 1089 | $chosen = 'class="wpinv-chosen"'; |
| 1090 | 1090 | } else { |
| 1091 | 1091 | $chosen = ''; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - if( !empty( $args['onchange'] ) ) { |
|
| 1095 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 1094 | + if (!empty($args['onchange'])) { |
|
| 1095 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 1096 | 1096 | } else { |
| 1097 | 1097 | $onchange = ''; |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1100 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
| 1101 | 1101 | |
| 1102 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1103 | - $selected = selected( $option, $value, false ); |
|
| 1104 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1102 | + foreach ($args['options'] as $option => $name) { |
|
| 1103 | + $selected = selected($option, $value, false); |
|
| 1104 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | $html .= '</select>'; |
| 1108 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1108 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1109 | 1109 | |
| 1110 | 1110 | echo $html; |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | -function wpinv_color_select_callback( $args ) { |
|
| 1113 | +function wpinv_color_select_callback($args) { |
|
| 1114 | 1114 | global $wpinv_options; |
| 1115 | 1115 | |
| 1116 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1116 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1117 | 1117 | |
| 1118 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1119 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1118 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1119 | + $value = $wpinv_options[$args['id']]; |
|
| 1120 | 1120 | } else { |
| 1121 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1121 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1124 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 1125 | 1125 | |
| 1126 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1127 | - $selected = selected( $option, $value, false ); |
|
| 1128 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1126 | + foreach ($args['options'] as $option => $color) { |
|
| 1127 | + $selected = selected($option, $value, false); |
|
| 1128 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | $html .= '</select>'; |
| 1132 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1132 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1133 | 1133 | |
| 1134 | 1134 | echo $html; |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | -function wpinv_rich_editor_callback( $args ) { |
|
| 1137 | +function wpinv_rich_editor_callback($args) { |
|
| 1138 | 1138 | global $wpinv_options, $wp_version; |
| 1139 | 1139 | |
| 1140 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1140 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1141 | 1141 | |
| 1142 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1143 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1142 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1143 | + $value = $wpinv_options[$args['id']]; |
|
| 1144 | 1144 | |
| 1145 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1146 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1145 | + if (empty($args['allow_blank']) && empty($value)) { |
|
| 1146 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1147 | 1147 | } |
| 1148 | 1148 | } else { |
| 1149 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1149 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1152 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 1153 | 1153 | |
| 1154 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1154 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 1155 | 1155 | ob_start(); |
| 1156 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1156 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
| 1157 | 1157 | $html = ob_get_clean(); |
| 1158 | 1158 | } else { |
| 1159 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1159 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1162 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1163 | 1163 | |
| 1164 | 1164 | echo $html; |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | -function wpinv_upload_callback( $args ) { |
|
| 1167 | +function wpinv_upload_callback($args) { |
|
| 1168 | 1168 | global $wpinv_options; |
| 1169 | 1169 | |
| 1170 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1170 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1171 | 1171 | |
| 1172 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1172 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1173 | 1173 | $value = $wpinv_options[$args['id']]; |
| 1174 | 1174 | } else { |
| 1175 | 1175 | $value = isset($args['std']) ? $args['std'] : ''; |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1179 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1180 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1181 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1178 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1179 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1180 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 1181 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1182 | 1182 | |
| 1183 | 1183 | echo $html; |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | -function wpinv_color_callback( $args ) { |
|
| 1186 | +function wpinv_color_callback($args) { |
|
| 1187 | 1187 | global $wpinv_options; |
| 1188 | 1188 | |
| 1189 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1189 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1190 | 1190 | |
| 1191 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1192 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1191 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1192 | + $value = $wpinv_options[$args['id']]; |
|
| 1193 | 1193 | } else { |
| 1194 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1194 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1197 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
| 1198 | 1198 | |
| 1199 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1200 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1199 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
| 1200 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1201 | 1201 | |
| 1202 | 1202 | echo $html; |
| 1203 | 1203 | } |
@@ -1205,9 +1205,9 @@ discard block |
||
| 1205 | 1205 | function wpinv_country_states_callback($args) { |
| 1206 | 1206 | global $wpinv_options; |
| 1207 | 1207 | |
| 1208 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1208 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1209 | 1209 | |
| 1210 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1210 | + if (isset($args['placeholder'])) { |
|
| 1211 | 1211 | $placeholder = $args['placeholder']; |
| 1212 | 1212 | } else { |
| 1213 | 1213 | $placeholder = ''; |
@@ -1215,17 +1215,17 @@ discard block |
||
| 1215 | 1215 | |
| 1216 | 1216 | $states = wpinv_get_country_states(); |
| 1217 | 1217 | |
| 1218 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1219 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1220 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1218 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
| 1219 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1220 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 1221 | 1221 | |
| 1222 | - foreach ( $states as $option => $name ) { |
|
| 1223 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1224 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1222 | + foreach ($states as $option => $name) { |
|
| 1223 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
| 1224 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | $html .= '</select>'; |
| 1228 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1228 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1229 | 1229 | |
| 1230 | 1230 | echo $html; |
| 1231 | 1231 | } |
@@ -1240,25 +1240,25 @@ discard block |
||
| 1240 | 1240 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
| 1241 | 1241 | <thead> |
| 1242 | 1242 | <tr> |
| 1243 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
| 1244 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
| 1245 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
| 1246 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
| 1247 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
| 1248 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
| 1243 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
| 1244 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
| 1245 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
| 1246 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
| 1247 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
| 1248 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
| 1249 | 1249 | </tr> |
| 1250 | 1250 | </thead> |
| 1251 | 1251 | <tbody> |
| 1252 | - <?php if( !empty( $rates ) ) : ?> |
|
| 1253 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
| 1252 | + <?php if (!empty($rates)) : ?> |
|
| 1253 | + <?php foreach ($rates as $key => $rate) : ?> |
|
| 1254 | 1254 | <?php |
| 1255 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
| 1255 | + $sanitized_key = wpinv_sanitize_key($key); |
|
| 1256 | 1256 | ?> |
| 1257 | 1257 | <tr> |
| 1258 | 1258 | <td class="wpinv_tax_country"> |
| 1259 | 1259 | <?php |
| 1260 | - echo wpinv_html_select( array( |
|
| 1261 | - 'options' => wpinv_get_country_list( true ), |
|
| 1260 | + echo wpinv_html_select(array( |
|
| 1261 | + 'options' => wpinv_get_country_list(true), |
|
| 1262 | 1262 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1263 | 1263 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1264 | 1264 | 'selected' => $rate['country'], |
@@ -1266,72 +1266,72 @@ discard block |
||
| 1266 | 1266 | 'show_option_none' => false, |
| 1267 | 1267 | 'class' => 'wpinv-tax-country', |
| 1268 | 1268 | 'chosen' => false, |
| 1269 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1270 | - ) ); |
|
| 1269 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1270 | + )); |
|
| 1271 | 1271 | ?> |
| 1272 | 1272 | </td> |
| 1273 | 1273 | <td class="wpinv_tax_state"> |
| 1274 | 1274 | <?php |
| 1275 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1276 | - if( !empty( $states ) ) { |
|
| 1277 | - echo wpinv_html_select( array( |
|
| 1278 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1275 | + $states = wpinv_get_country_states($rate['country']); |
|
| 1276 | + if (!empty($states)) { |
|
| 1277 | + echo wpinv_html_select(array( |
|
| 1278 | + 'options' => array_merge(array('' => ''), $states), |
|
| 1279 | 1279 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1280 | 1280 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1281 | 1281 | 'selected' => $rate['state'], |
| 1282 | 1282 | 'show_option_all' => false, |
| 1283 | 1283 | 'show_option_none' => false, |
| 1284 | 1284 | 'chosen' => false, |
| 1285 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1286 | - ) ); |
|
| 1285 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
| 1286 | + )); |
|
| 1287 | 1287 | } else { |
| 1288 | - echo wpinv_html_text( array( |
|
| 1288 | + echo wpinv_html_text(array( |
|
| 1289 | 1289 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
| 1290 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1290 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
| 1291 | 1291 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1292 | - ) ); |
|
| 1292 | + )); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | ?> |
| 1295 | 1295 | </td> |
| 1296 | 1296 | <td class="wpinv_tax_global"> |
| 1297 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
| 1298 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1297 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
| 1298 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1299 | 1299 | </td> |
| 1300 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="0.10" min="0.00" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
| 1301 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
| 1302 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1300 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="0.10" min="0.00" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
| 1301 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
| 1302 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1303 | 1303 | </tr> |
| 1304 | 1304 | <?php endforeach; ?> |
| 1305 | 1305 | <?php else : ?> |
| 1306 | 1306 | <tr> |
| 1307 | 1307 | <td class="wpinv_tax_country"> |
| 1308 | 1308 | <?php |
| 1309 | - echo wpinv_html_select( array( |
|
| 1310 | - 'options' => wpinv_get_country_list( true ), |
|
| 1309 | + echo wpinv_html_select(array( |
|
| 1310 | + 'options' => wpinv_get_country_list(true), |
|
| 1311 | 1311 | 'name' => 'tax_rates[0][country]', |
| 1312 | 1312 | 'show_option_all' => false, |
| 1313 | 1313 | 'show_option_none' => false, |
| 1314 | 1314 | 'class' => 'wpinv-tax-country', |
| 1315 | 1315 | 'chosen' => false, |
| 1316 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1317 | - ) ); ?> |
|
| 1316 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1317 | + )); ?> |
|
| 1318 | 1318 | </td> |
| 1319 | 1319 | <td class="wpinv_tax_state"> |
| 1320 | - <?php echo wpinv_html_text( array( |
|
| 1320 | + <?php echo wpinv_html_text(array( |
|
| 1321 | 1321 | 'name' => 'tax_rates[0][state]' |
| 1322 | - ) ); ?> |
|
| 1322 | + )); ?> |
|
| 1323 | 1323 | </td> |
| 1324 | 1324 | <td class="wpinv_tax_global"> |
| 1325 | 1325 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
| 1326 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1326 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1327 | 1327 | </td> |
| 1328 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="0.10" min="0.00" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
| 1328 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="0.10" min="0.00" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
| 1329 | 1329 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
| 1330 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1330 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1331 | 1331 | </tr> |
| 1332 | 1332 | <?php endif; ?> |
| 1333 | 1333 | </tbody> |
| 1334 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
| 1334 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
| 1335 | 1335 | </table> |
| 1336 | 1336 | <?php |
| 1337 | 1337 | echo ob_get_clean(); |
@@ -1342,34 +1342,34 @@ discard block |
||
| 1342 | 1342 | ob_start(); ?> |
| 1343 | 1343 | </td><tr> |
| 1344 | 1344 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 1345 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1346 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 1345 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1346 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 1347 | 1347 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 1348 | 1348 | <thead> |
| 1349 | 1349 | <tr> |
| 1350 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 1351 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 1352 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 1350 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 1351 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 1352 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 1353 | 1353 | </tr> |
| 1354 | 1354 | </thead> |
| 1355 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1355 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1356 | 1356 | <tbody> |
| 1357 | 1357 | </tbody> |
| 1358 | 1358 | </table> |
| 1359 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1359 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1360 | 1360 | <?php |
| 1361 | 1361 | echo ob_get_clean(); |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1365 | - echo wp_kses_post( $args['desc'] ); |
|
| 1364 | +function wpinv_descriptive_text_callback($args) { |
|
| 1365 | + echo wp_kses_post($args['desc']); |
|
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | -function wpinv_hook_callback( $args ) { |
|
| 1369 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1368 | +function wpinv_hook_callback($args) { |
|
| 1369 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | function wpinv_set_settings_cap() { |
| 1373 | 1373 | return 'manage_options'; |
| 1374 | 1374 | } |
| 1375 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1375 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
@@ -1,61 +1,61 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function wpinv_print_errors() { |
| 8 | 8 | $errors = wpinv_get_errors(); |
| 9 | 9 | |
| 10 | - if ( $errors ) { |
|
| 11 | - $classes = apply_filters( 'wpinv_error_class', array( |
|
| 10 | + if ($errors) { |
|
| 11 | + $classes = apply_filters('wpinv_error_class', array( |
|
| 12 | 12 | 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-error' |
| 13 | - ) ); |
|
| 14 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 13 | + )); |
|
| 14 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 15 | 15 | // Loop error codes and display errors |
| 16 | - foreach ( $errors as $error_id => $error ) { |
|
| 17 | - echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>'; |
|
| 16 | + foreach ($errors as $error_id => $error) { |
|
| 17 | + echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __('Error', 'invoicing') . '</strong>: ' . $error . '</p>'; |
|
| 18 | 18 | } |
| 19 | 19 | echo '</div>'; |
| 20 | 20 | wpinv_clear_errors(); |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | -add_action( 'wpinv_purchase_form_before_submit', 'wpinv_print_errors' ); |
|
| 24 | -add_action( 'wpinv_ajax_checkout_errors', 'wpinv_print_errors' ); |
|
| 23 | +add_action('wpinv_purchase_form_before_submit', 'wpinv_print_errors'); |
|
| 24 | +add_action('wpinv_ajax_checkout_errors', 'wpinv_print_errors'); |
|
| 25 | 25 | |
| 26 | 26 | function wpinv_get_errors() { |
| 27 | 27 | global $wpi_session; |
| 28 | 28 | |
| 29 | - return $wpi_session->get( 'wpinv_errors' ); |
|
| 29 | + return $wpi_session->get('wpinv_errors'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -function wpinv_set_error( $error_id, $error_message ) { |
|
| 32 | +function wpinv_set_error($error_id, $error_message) { |
|
| 33 | 33 | global $wpi_session; |
| 34 | 34 | |
| 35 | 35 | $errors = wpinv_get_errors(); |
| 36 | 36 | |
| 37 | - if ( ! $errors ) { |
|
| 37 | + if (!$errors) { |
|
| 38 | 38 | $errors = array(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $errors[ $error_id ] = $error_message; |
|
| 42 | - $wpi_session->set( 'wpinv_errors', $errors ); |
|
| 41 | + $errors[$error_id] = $error_message; |
|
| 42 | + $wpi_session->set('wpinv_errors', $errors); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_clear_errors() { |
| 46 | 46 | global $wpi_session; |
| 47 | 47 | |
| 48 | - $wpi_session->set( 'wpinv_errors', null ); |
|
| 48 | + $wpi_session->set('wpinv_errors', null); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -function wpinv_unset_error( $error_id ) { |
|
| 51 | +function wpinv_unset_error($error_id) { |
|
| 52 | 52 | global $wpi_session; |
| 53 | 53 | |
| 54 | 54 | $errors = wpinv_get_errors(); |
| 55 | 55 | |
| 56 | - if ( $errors ) { |
|
| 57 | - unset( $errors[ $error_id ] ); |
|
| 58 | - $wpi_session->set( 'wpinv_errors', $errors ); |
|
| 56 | + if ($errors) { |
|
| 57 | + unset($errors[$error_id]); |
|
| 58 | + $wpi_session->set('wpinv_errors', $errors); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | die(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
| 67 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 68 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
| 69 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 66 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
| 67 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
| 68 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
| 69 | + wp_die($message, $title, array('response' => $status)); |
|
| 70 | 70 | } |