@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
| 26 | - define( 'WPINV_VERSION', '2.5.4' ); |
|
| 26 | + define( 'WPINV_VERSION', '2.5.4' ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return $GLOBALS['invoicing']; |
|
| 46 | + return $GLOBALS['invoicing']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -15,20 +15,20 @@ discard block |
||
| 15 | 15 | * @package GetPaid |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -defined( 'ABSPATH' ) || exit; |
|
| 18 | +defined('ABSPATH') || exit; |
|
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
| 22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
| 26 | - define( 'WPINV_VERSION', '2.5.4' ); |
|
| 25 | +if (!defined('WPINV_VERSION')) { |
|
| 26 | + define('WPINV_VERSION', '2.5.4'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
| 31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function getpaid() { |
| 41 | 41 | |
| 42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
| 42 | + if (empty($GLOBALS['invoicing'])) { |
|
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @since 2.0.8 |
| 53 | 53 | */ |
| 54 | 54 | function getpaid_deactivation_hook() { |
| 55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
| 55 | + update_option('wpinv_flush_permalinks', 1); |
|
| 56 | 56 | } |
| 57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
| 57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Kickstart the plugin. |
| 67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
| 67 | +add_action('plugins_loaded', 'getpaid', -100); |
|
@@ -7,31 +7,31 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <div class='form-group'> |
| 15 | 15 | <label class="d-block"> |
| 16 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
| 16 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
| 17 | 17 | <input v-model="active_form_element.label" class="form-control" type="text"/> |
| 18 | 18 | </label> |
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <div class='form-group'> |
| 22 | 22 | <label class="d-block"> |
| 23 | - <span><?php esc_html_e( 'Max File Number', 'invoicing' ); ?></span> |
|
| 23 | + <span><?php esc_html_e('Max File Number', 'invoicing'); ?></span> |
|
| 24 | 24 | <input v-model="active_form_element.max_file_num" class="form-control" min="1" type="number" /> |
| 25 | - <small class="form-text text-muted"><?php _e( 'How many files can be uploaded?', 'invoicing' ); ?></small> |
|
| 25 | + <small class="form-text text-muted"><?php _e('How many files can be uploaded?', 'invoicing'); ?></small> |
|
| 26 | 26 | </label> |
| 27 | 27 | </div> |
| 28 | 28 | |
| 29 | 29 | <div class='form-group'> |
| 30 | 30 | <label class="d-block"> |
| 31 | - <span><?php esc_html_e( 'Allowed File types', 'invoicing' ); ?></span> |
|
| 31 | + <span><?php esc_html_e('Allowed File types', 'invoicing'); ?></span> |
|
| 32 | 32 | <gpselect2 class='form-control custom-select' v-model='active_form_element.file_types' multiple> |
| 33 | - <?php foreach ( getpaid_get_allowed_mime_types() as $ext_regex => $mime_type ) : ?> |
|
| 34 | - <option value="<?php echo esc_attr( $ext_regex ); ?>"><?php echo esc_html( "$mime_type" ) ?></option> |
|
| 33 | + <?php foreach (getpaid_get_allowed_mime_types() as $ext_regex => $mime_type) : ?> |
|
| 34 | + <option value="<?php echo esc_attr($ext_regex); ?>"><?php echo esc_html("$mime_type") ?></option> |
|
| 35 | 35 | <?php endforeach; ?> |
| 36 | 36 | </gpselect2> |
| 37 | 37 | </label> |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | <div class='form-group'> |
| 41 | 41 | <label class="d-block"> |
| 42 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
| 43 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
| 44 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
| 42 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
| 43 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
| 44 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
| 45 | 45 | </label> |
| 46 | 46 | </div> |
| 47 | 47 | |
@@ -49,20 +49,20 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | <div class='form-group form-check'> |
| 51 | 51 | <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' /> |
| 52 | - <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label> |
|
| 52 | + <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label> |
|
| 53 | 53 | </div> |
| 54 | 54 | |
| 55 | 55 | <div class='form-group form-check'> |
| 56 | 56 | <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' /> |
| 57 | - <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label> |
|
| 57 | + <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label> |
|
| 58 | 58 | </div> |
| 59 | 59 | |
| 60 | 60 | <hr class='featurette-divider mt-4'> |
| 61 | 61 | |
| 62 | 62 | <div class='form-group'> |
| 63 | 63 | <label class="d-block"> |
| 64 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
| 64 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
| 65 | 65 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
| 66 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
| 66 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
| 67 | 67 | </label> |
| 68 | 68 | </div> |
@@ -7,15 +7,15 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <label><span v-html="form_element.label"></span></label> |
| 15 | 15 | <div class="d-flex w-100 flex-column align-items-center justify-content-center p-2" style="height: 200px; border: 3px dashed rgb(136, 136, 136); cursor: pointer;"> |
| 16 | 16 | <div class="h5 text-dark"> |
| 17 | - <span v-if="form_element.max_file_num > 1"><?php _e( 'Drag files to this area or click to upload', 'invoicing' ); ?></span> |
|
| 18 | - <span v-if="form_element.max_file_num < 2"><?php _e( 'Drag your file to this area or click to upload', 'invoicing' ); ?></span> |
|
| 17 | + <span v-if="form_element.max_file_num > 1"><?php _e('Drag files to this area or click to upload', 'invoicing'); ?></span> |
|
| 18 | + <span v-if="form_element.max_file_num < 2"><?php _e('Drag your file to this area or click to upload', 'invoicing'); ?></span> |
|
| 19 | 19 | </div> |
| 20 | 20 | <small v-if='form_element.description' class='form-text text-muted' v-html='form_element.description'></small> |
| 21 | 21 | </div> |
@@ -21,22 +21,22 @@ |
||
| 21 | 21 | |
| 22 | 22 | foreach ( $file_types as $file_type ) { |
| 23 | 23 | |
| 24 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
| 25 | - $types[] = $all_types[ $file_type ]; |
|
| 26 | - $file_type = explode( '|', $file_type ); |
|
| 24 | + if ( isset( $all_types[ $file_type ] ) ) { |
|
| 25 | + $types[] = $all_types[ $file_type ]; |
|
| 26 | + $file_type = explode( '|', $file_type ); |
|
| 27 | 27 | |
| 28 | - foreach ( $file_type as $type ) { |
|
| 29 | - $type = trim( $type ); |
|
| 30 | - $types[] = ".$type"; |
|
| 31 | - $_types[] = $type; |
|
| 32 | - } |
|
| 28 | + foreach ( $file_type as $type ) { |
|
| 29 | + $type = trim( $type ); |
|
| 30 | + $types[] = ".$type"; |
|
| 31 | + $_types[] = $type; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | if ( ! empty( $required ) ) { |
| 39 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 39 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | ?> |
@@ -7,26 +7,26 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | - |
|
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | -$id = esc_attr( $id ); |
|
| 15 | -$_id = $id . uniqid( '_' ); |
|
| 16 | -$max_file_num = empty( $max_file_num ) ? 1 : absint( $max_file_num ); |
|
| 17 | -$file_types = empty( $file_types ) ? array( 'jpg|jpeg|jpe', 'gif', 'png' ) : $file_types; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | + |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | +$id = esc_attr($id); |
|
| 15 | +$_id = $id . uniqid('_'); |
|
| 16 | +$max_file_num = empty($max_file_num) ? 1 : absint($max_file_num); |
|
| 17 | +$file_types = empty($file_types) ? array('jpg|jpeg|jpe', 'gif', 'png') : $file_types; |
|
| 18 | 18 | $all_types = getpaid_get_allowed_mime_types(); |
| 19 | 19 | $types = array(); |
| 20 | 20 | $_types = array(); |
| 21 | 21 | |
| 22 | -foreach ( $file_types as $file_type ) { |
|
| 22 | +foreach ($file_types as $file_type) { |
|
| 23 | 23 | |
| 24 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
| 25 | - $types[] = $all_types[ $file_type ]; |
|
| 26 | - $file_type = explode( '|', $file_type ); |
|
| 24 | + if (isset($all_types[$file_type])) { |
|
| 25 | + $types[] = $all_types[$file_type]; |
|
| 26 | + $file_type = explode('|', $file_type); |
|
| 27 | 27 | |
| 28 | - foreach ( $file_type as $type ) { |
|
| 29 | - $type = trim( $type ); |
|
| 28 | + foreach ($file_type as $type) { |
|
| 29 | + $type = trim($type); |
|
| 30 | 30 | $types[] = ".$type"; |
| 31 | 31 | $_types[] = $type; |
| 32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -if ( ! empty( $required ) ) { |
|
| 38 | +if (!empty($required)) { |
|
| 39 | 39 | $label .= "<span class='text-danger'> *</span>"; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | <label><span v-html="form_element.label"></span></label> |
| 45 | 45 | |
| 46 | -<div class="form-group <?php echo sanitize_html_class( $label_class ); ?>" data-name="<?php echo esc_attr( $id ); ?>" data-max="<?php echo esc_attr( $max_file_num ); ?>"> |
|
| 47 | - <label for="<?php echo esc_attr( $id ); ?>"><?php echo wp_kses_post( $label ); ?></label> |
|
| 48 | - <input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr( $id ); ?>" accept="<?php echo esc_attr( implode( ', ', $types ) ); ?>" data-extensions="<?php echo esc_attr( wp_json_encode( $_types ) ); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>> |
|
| 46 | +<div class="form-group <?php echo sanitize_html_class($label_class); ?>" data-name="<?php echo esc_attr($id); ?>" data-max="<?php echo esc_attr($max_file_num); ?>"> |
|
| 47 | + <label for="<?php echo esc_attr($id); ?>"><?php echo wp_kses_post($label); ?></label> |
|
| 48 | + <input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr($id); ?>" accept="<?php echo esc_attr(implode(', ', $types)); ?>" data-extensions="<?php echo esc_attr(wp_json_encode($_types)); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>> |
|
| 49 | 49 | |
| 50 | - <label for="<?php echo esc_attr( $id ); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2"> |
|
| 50 | + <label for="<?php echo esc_attr($id); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2"> |
|
| 51 | 51 | <div class="h5 text-dark"> |
| 52 | - <?php echo _n( 'Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing' ); ?> |
|
| 52 | + <?php echo _n('Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing'); ?> |
|
| 53 | 53 | </div> |
| 54 | - <?php if ( ! empty( $description ) ) : ?> |
|
| 55 | - <small class="form-text text-muted"><?php echo wp_kses_post( $description ); ?></small> |
|
| 54 | + <?php if (!empty($description)) : ?> |
|
| 55 | + <small class="form-text text-muted"><?php echo wp_kses_post($description); ?></small> |
|
| 56 | 56 | <?php endif; ?> |
| 57 | 57 | </label> |
| 58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | <div class="form-row mb-3 d-none getpaid-progress-template"> |
| 62 | 62 | |
| 63 | 63 | <div class="overflow-hidden text-nowrap col-7 col-sm-4"> |
| 64 | - <a href="" class="close float-none" title="<?php esc_attr_e( 'Remove File', 'invoicing' ); ?>">×<span class="sr-only"><?php _e( 'Close', 'invoicing' ); ?></span></a> |
|
| 64 | + <a href="" class="close float-none" title="<?php esc_attr_e('Remove File', 'invoicing'); ?>">×<span class="sr-only"><?php _e('Close', 'invoicing'); ?></span></a> |
|
| 65 | 65 | <i class="fa fa-file" aria-hidden="true"></i> <span class="getpaid-progress-file-name"></span> |
| 66 | 66 | </div> |
| 67 | 67 | |
@@ -14,70 +14,70 @@ discard block |
||
| 14 | 14 | class WPInv_Ajax { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Hook in ajax handlers. |
|
| 18 | - */ |
|
| 19 | - public static function init() { |
|
| 20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
| 21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
| 22 | - self::add_ajax_events(); |
|
| 17 | + * Hook in ajax handlers. |
|
| 18 | + */ |
|
| 19 | + public static function init() { |
|
| 20 | + add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
| 21 | + add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
| 22 | + self::add_ajax_events(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * Set GetPaid AJAX constant and headers. |
|
| 27 | - */ |
|
| 28 | - public static function define_ajax() { |
|
| 29 | - |
|
| 30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
| 31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
| 32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
| 33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
| 34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
| 35 | - } |
|
| 36 | - $GLOBALS['wpdb']->hide_errors(); |
|
| 37 | - } |
|
| 26 | + * Set GetPaid AJAX constant and headers. |
|
| 27 | + */ |
|
| 28 | + public static function define_ajax() { |
|
| 29 | + |
|
| 30 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
| 31 | + getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
| 32 | + getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
| 33 | + if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
| 34 | + /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
| 35 | + } |
|
| 36 | + $GLOBALS['wpdb']->hide_errors(); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Send headers for GetPaid Ajax Requests. |
|
| 43 | - * |
|
| 44 | - * @since 1.0.18 |
|
| 45 | - */ |
|
| 46 | - private static function wpinv_ajax_headers() { |
|
| 47 | - if ( ! headers_sent() ) { |
|
| 48 | - send_origin_headers(); |
|
| 49 | - send_nosniff_header(); |
|
| 50 | - nocache_headers(); |
|
| 51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 52 | - header( 'X-Robots-Tag: noindex' ); |
|
| 53 | - status_header( 200 ); |
|
| 54 | - } |
|
| 42 | + * Send headers for GetPaid Ajax Requests. |
|
| 43 | + * |
|
| 44 | + * @since 1.0.18 |
|
| 45 | + */ |
|
| 46 | + private static function wpinv_ajax_headers() { |
|
| 47 | + if ( ! headers_sent() ) { |
|
| 48 | + send_origin_headers(); |
|
| 49 | + send_nosniff_header(); |
|
| 50 | + nocache_headers(); |
|
| 51 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 52 | + header( 'X-Robots-Tag: noindex' ); |
|
| 53 | + status_header( 200 ); |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * Check for GetPaid Ajax request and fire action. |
|
| 59 | - */ |
|
| 60 | - public static function do_wpinv_ajax() { |
|
| 61 | - global $wp_query; |
|
| 58 | + * Check for GetPaid Ajax request and fire action. |
|
| 59 | + */ |
|
| 60 | + public static function do_wpinv_ajax() { |
|
| 61 | + global $wp_query; |
|
| 62 | 62 | |
| 63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
| 64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
| 65 | - } |
|
| 63 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
| 64 | + $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
| 67 | + $action = $wp_query->get( 'wpinv-ajax' ); |
|
| 68 | 68 | |
| 69 | - if ( $action ) { |
|
| 70 | - self::wpinv_ajax_headers(); |
|
| 71 | - $action = sanitize_text_field( $action ); |
|
| 72 | - do_action( 'wpinv_ajax_' . $action ); |
|
| 73 | - wp_die(); |
|
| 74 | - } |
|
| 69 | + if ( $action ) { |
|
| 70 | + self::wpinv_ajax_headers(); |
|
| 71 | + $action = sanitize_text_field( $action ); |
|
| 72 | + do_action( 'wpinv_ajax_' . $action ); |
|
| 73 | + wp_die(); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Hook in ajax methods. |
|
| 80 | - */ |
|
| 79 | + * Hook in ajax methods. |
|
| 80 | + */ |
|
| 81 | 81 | public static function add_ajax_events() { |
| 82 | 82 | |
| 83 | 83 | // array( 'event' => is_frontend ) |
@@ -261,18 +261,18 @@ discard block |
||
| 261 | 261 | check_ajax_referer( 'getpaid_form_nonce' ); |
| 262 | 262 | |
| 263 | 263 | // Is the request set up correctly? |
| 264 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
| 265 | - echo aui()->alert( |
|
| 266 | - array( |
|
| 267 | - 'type' => 'warning', |
|
| 268 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
| 269 | - ) |
|
| 264 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
| 265 | + echo aui()->alert( |
|
| 266 | + array( |
|
| 267 | + 'type' => 'warning', |
|
| 268 | + 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
| 269 | + ) |
|
| 270 | 270 | ); |
| 271 | 271 | exit; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // Payment form or button? |
| 275 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 275 | + if ( ! empty( $_GET['form'] ) ) { |
|
| 276 | 276 | $form = urldecode( $_GET['form'] ); |
| 277 | 277 | |
| 278 | 278 | if ( false !== strpos( $form, '|' ) ) { |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | getpaid_display_payment_form( $form ); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
| 330 | - getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
| 329 | + } else if( ! empty( $_GET['invoice'] ) ) { |
|
| 330 | + getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
| 331 | 331 | } else { |
| 332 | - $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
| 333 | - getpaid_display_item_payment_form( $items ); |
|
| 332 | + $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
| 333 | + getpaid_display_item_payment_form( $items ); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | exit; |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | if ( is_wp_error( $error ) ) { |
| 652 | 652 | $alert = $error->get_error_message(); |
| 653 | 653 | wp_send_json_success( compact( 'alert' ) ); |
| 654 | - } |
|
| 654 | + } |
|
| 655 | 655 | |
| 656 | 656 | // Update totals. |
| 657 | 657 | $invoice->recalculate_total(); |
@@ -1085,12 +1085,12 @@ discard block |
||
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | /** |
| 1088 | - * Handles file uploads. |
|
| 1089 | - * |
|
| 1090 | - * @since 1.0.0 |
|
| 1091 | - * @return void |
|
| 1092 | - */ |
|
| 1093 | - public static function file_upload() { |
|
| 1088 | + * Handles file uploads. |
|
| 1089 | + * |
|
| 1090 | + * @since 1.0.0 |
|
| 1091 | + * @return void |
|
| 1092 | + */ |
|
| 1093 | + public static function file_upload() { |
|
| 1094 | 1094 | |
| 1095 | 1095 | // Check nonce. |
| 1096 | 1096 | check_ajax_referer( 'getpaid_form_nonce' ); |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | |
| 1152 | 1152 | wp_send_json_success( $response ); |
| 1153 | 1153 | |
| 1154 | - } |
|
| 1154 | + } |
|
| 1155 | 1155 | |
| 1156 | 1156 | } |
| 1157 | 1157 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | * Hook in ajax handlers. |
| 18 | 18 | */ |
| 19 | 19 | public static function init() { |
| 20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
| 21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
| 20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
| 21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
| 22 | 22 | self::add_ajax_events(); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public static function define_ajax() { |
| 29 | 29 | |
| 30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
| 31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
| 32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
| 33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
| 34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
| 30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
| 31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
| 32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
| 33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
| 34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
| 35 | 35 | } |
| 36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
| 37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | * @since 1.0.18 |
| 45 | 45 | */ |
| 46 | 46 | private static function wpinv_ajax_headers() { |
| 47 | - if ( ! headers_sent() ) { |
|
| 47 | + if (!headers_sent()) { |
|
| 48 | 48 | send_origin_headers(); |
| 49 | 49 | send_nosniff_header(); |
| 50 | 50 | nocache_headers(); |
| 51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 52 | - header( 'X-Robots-Tag: noindex' ); |
|
| 53 | - status_header( 200 ); |
|
| 51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
| 52 | + header('X-Robots-Tag: noindex'); |
|
| 53 | + status_header(200); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | public static function do_wpinv_ajax() { |
| 61 | 61 | global $wp_query; |
| 62 | 62 | |
| 63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
| 64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
| 63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
| 64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
| 67 | + $action = $wp_query->get('wpinv-ajax'); |
|
| 68 | 68 | |
| 69 | - if ( $action ) { |
|
| 69 | + if ($action) { |
|
| 70 | 70 | self::wpinv_ajax_headers(); |
| 71 | - $action = sanitize_text_field( $action ); |
|
| 72 | - do_action( 'wpinv_ajax_' . $action ); |
|
| 71 | + $action = sanitize_text_field($action); |
|
| 72 | + do_action('wpinv_ajax_' . $action); |
|
| 73 | 73 | wp_die(); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -106,36 +106,36 @@ discard block |
||
| 106 | 106 | 'file_upload' => true, |
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
| 110 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 111 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 109 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
| 110 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 111 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 112 | 112 | |
| 113 | - if ( $nopriv ) { |
|
| 114 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 115 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 116 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 113 | + if ($nopriv) { |
|
| 114 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 115 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 116 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public static function add_note() { |
| 122 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
| 122 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
| 123 | 123 | |
| 124 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 124 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 125 | 125 | die(-1); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $post_id = absint( $_POST['post_id'] ); |
|
| 129 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
| 130 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
| 128 | + $post_id = absint($_POST['post_id']); |
|
| 129 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
| 130 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
| 131 | 131 | |
| 132 | 132 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
| 133 | 133 | |
| 134 | - if ( $post_id > 0 ) { |
|
| 135 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
| 134 | + if ($post_id > 0) { |
|
| 135 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
| 136 | 136 | |
| 137 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
| 138 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
| 137 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
| 138 | + wpinv_get_invoice_note_line_item($note_id); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -143,16 +143,16 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | public static function delete_note() { |
| 146 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
| 146 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
| 147 | 147 | |
| 148 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 148 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 149 | 149 | die(-1); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $note_id = (int)$_POST['note_id']; |
|
| 152 | + $note_id = (int) $_POST['note_id']; |
|
| 153 | 153 | |
| 154 | - if ( $note_id > 0 ) { |
|
| 155 | - wp_delete_comment( $note_id, true ); |
|
| 154 | + if ($note_id > 0) { |
|
| 155 | + wp_delete_comment($note_id, true); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | die(); |
@@ -170,34 +170,34 @@ discard block |
||
| 170 | 170 | public static function get_billing_details() { |
| 171 | 171 | |
| 172 | 172 | // Verify nonce. |
| 173 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 173 | + check_ajax_referer('wpinv-nonce'); |
|
| 174 | 174 | |
| 175 | 175 | // Can the user manage the plugin? |
| 176 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 176 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 177 | 177 | die(-1); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Do we have a user id? |
| 181 | 181 | $user_id = $_GET['user_id']; |
| 182 | 182 | |
| 183 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
| 183 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
| 184 | 184 | die(-1); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // Fetch the billing details. |
| 188 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
| 189 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
| 188 | + $billing_details = wpinv_get_user_address($user_id); |
|
| 189 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
| 190 | 190 | |
| 191 | 191 | // unset the user id and email. |
| 192 | - $to_ignore = array( 'user_id', 'email' ); |
|
| 192 | + $to_ignore = array('user_id', 'email'); |
|
| 193 | 193 | |
| 194 | - foreach ( $to_ignore as $key ) { |
|
| 195 | - if ( isset( $billing_details[ $key ] ) ) { |
|
| 196 | - unset( $billing_details[ $key ] ); |
|
| 194 | + foreach ($to_ignore as $key) { |
|
| 195 | + if (isset($billing_details[$key])) { |
|
| 196 | + unset($billing_details[$key]); |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - wp_send_json_success( $billing_details ); |
|
| 200 | + wp_send_json_success($billing_details); |
|
| 201 | 201 | |
| 202 | 202 | } |
| 203 | 203 | |
@@ -207,47 +207,47 @@ discard block |
||
| 207 | 207 | public static function check_new_user_email() { |
| 208 | 208 | |
| 209 | 209 | // Verify nonce. |
| 210 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 210 | + check_ajax_referer('wpinv-nonce'); |
|
| 211 | 211 | |
| 212 | 212 | // Can the user manage the plugin? |
| 213 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 213 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 214 | 214 | die(-1); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // We need an email address. |
| 218 | - if ( empty( $_GET['email'] ) ) { |
|
| 219 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
| 218 | + if (empty($_GET['email'])) { |
|
| 219 | + _e("Provide the new user's email address", 'invoicing'); |
|
| 220 | 220 | exit; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Ensure the email is valid. |
| 224 | - $email = sanitize_text_field( $_GET['email'] ); |
|
| 225 | - if ( ! is_email( $email ) ) { |
|
| 226 | - _e( 'Invalid email address', 'invoicing' ); |
|
| 224 | + $email = sanitize_text_field($_GET['email']); |
|
| 225 | + if (!is_email($email)) { |
|
| 226 | + _e('Invalid email address', 'invoicing'); |
|
| 227 | 227 | exit; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // And it does not exist. |
| 231 | - $id = email_exists( $email ); |
|
| 232 | - if ( $id ) { |
|
| 233 | - wp_send_json_success( compact( 'id' ) ); |
|
| 231 | + $id = email_exists($email); |
|
| 232 | + if ($id) { |
|
| 233 | + wp_send_json_success(compact('id')); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - wp_send_json_success( true ); |
|
| 236 | + wp_send_json_success(true); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public static function run_tool() { |
| 240 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 241 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 240 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 241 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 242 | 242 | die(-1); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
| 245 | + $tool = sanitize_text_field($_POST['tool']); |
|
| 246 | 246 | |
| 247 | - do_action( 'wpinv_run_tool' ); |
|
| 247 | + do_action('wpinv_run_tool'); |
|
| 248 | 248 | |
| 249 | - if ( !empty( $tool ) ) { |
|
| 250 | - do_action( 'wpinv_tool_' . $tool ); |
|
| 249 | + if (!empty($tool)) { |
|
| 250 | + do_action('wpinv_tool_' . $tool); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
@@ -258,43 +258,43 @@ discard block |
||
| 258 | 258 | global $getpaid_force_checkbox; |
| 259 | 259 | |
| 260 | 260 | // Check nonce. |
| 261 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 261 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 262 | 262 | |
| 263 | 263 | // Is the request set up correctly? |
| 264 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
| 264 | + if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) { |
|
| 265 | 265 | echo aui()->alert( |
| 266 | 266 | array( |
| 267 | 267 | 'type' => 'warning', |
| 268 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
| 268 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
| 269 | 269 | ) |
| 270 | 270 | ); |
| 271 | 271 | exit; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // Payment form or button? |
| 275 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 276 | - $form = urldecode( $_GET['form'] ); |
|
| 275 | + if (!empty($_GET['form'])) { |
|
| 276 | + $form = urldecode($_GET['form']); |
|
| 277 | 277 | |
| 278 | - if ( false !== strpos( $form, '|' ) ) { |
|
| 279 | - $form_pos = strpos( $form, '|' ); |
|
| 280 | - $_items = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) ); |
|
| 281 | - $form = substr( $form, 0, $form_pos ); |
|
| 278 | + if (false !== strpos($form, '|')) { |
|
| 279 | + $form_pos = strpos($form, '|'); |
|
| 280 | + $_items = getpaid_convert_items_to_array(substr($form, $form_pos + 1)); |
|
| 281 | + $form = substr($form, 0, $form_pos); |
|
| 282 | 282 | |
| 283 | 283 | // Retrieve appropriate payment form. |
| 284 | - $payment_form = new GetPaid_Payment_Form( $form ); |
|
| 285 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 284 | + $payment_form = new GetPaid_Payment_Form($form); |
|
| 285 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 286 | 286 | |
| 287 | 287 | $items = array(); |
| 288 | 288 | $item_ids = array(); |
| 289 | 289 | |
| 290 | - foreach ( $_items as $item_id => $qty ) { |
|
| 291 | - if ( ! in_array( $item_id, $item_ids ) ) { |
|
| 292 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 293 | - $item->set_quantity( $qty ); |
|
| 290 | + foreach ($_items as $item_id => $qty) { |
|
| 291 | + if (!in_array($item_id, $item_ids)) { |
|
| 292 | + $item = new GetPaid_Form_Item($item_id); |
|
| 293 | + $item->set_quantity($qty); |
|
| 294 | 294 | |
| 295 | - if ( 0 == $qty ) { |
|
| 296 | - $item->set_allow_quantities( true ); |
|
| 297 | - $item->set_is_required( false ); |
|
| 295 | + if (0 == $qty) { |
|
| 296 | + $item->set_allow_quantities(true); |
|
| 297 | + $item->set_is_required(false); |
|
| 298 | 298 | $getpaid_force_checkbox = true; |
| 299 | 299 | } |
| 300 | 300 | |
@@ -303,10 +303,10 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if ( ! $payment_form->is_default() ) { |
|
| 306 | + if (!$payment_form->is_default()) { |
|
| 307 | 307 | |
| 308 | - foreach ( $payment_form->get_items() as $item ) { |
|
| 309 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
| 308 | + foreach ($payment_form->get_items() as $item) { |
|
| 309 | + if (!in_array($item->get_id(), $item_ids)) { |
|
| 310 | 310 | $item_ids[] = $item->get_id(); |
| 311 | 311 | $items[] = $item; |
| 312 | 312 | } |
@@ -314,23 +314,23 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $payment_form->set_items( $items ); |
|
| 318 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $_items ) ); |
|
| 319 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
| 317 | + $payment_form->set_items($items); |
|
| 318 | + $extra_items = esc_attr(getpaid_convert_items_to_string($_items)); |
|
| 319 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
| 320 | 320 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
| 321 | 321 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
| 322 | - $payment_form->display( $extra_items ); |
|
| 322 | + $payment_form->display($extra_items); |
|
| 323 | 323 | $getpaid_force_checkbox = false; |
| 324 | 324 | |
| 325 | 325 | } else { |
| 326 | - getpaid_display_payment_form( $form ); |
|
| 326 | + getpaid_display_payment_form($form); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
| 330 | - getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
| 329 | + } else if (!empty($_GET['invoice'])) { |
|
| 330 | + getpaid_display_invoice_payment_form(urldecode($_GET['invoice'])); |
|
| 331 | 331 | } else { |
| 332 | - $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
| 333 | - getpaid_display_item_payment_form( $items ); |
|
| 332 | + $items = getpaid_convert_items_to_array(urldecode($_GET['item'])); |
|
| 333 | + getpaid_display_item_payment_form($items); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | exit; |
@@ -345,17 +345,17 @@ discard block |
||
| 345 | 345 | public static function payment_form() { |
| 346 | 346 | |
| 347 | 347 | // Check nonce. |
| 348 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 348 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 349 | 349 | |
| 350 | 350 | // ... form fields... |
| 351 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 352 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
| 351 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
| 352 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
| 353 | 353 | exit; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Process the payment form. |
| 357 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
| 358 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
| 357 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
| 358 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
| 359 | 359 | $checkout->process_checkout(); |
| 360 | 360 | |
| 361 | 361 | exit; |
@@ -368,55 +368,55 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | public static function get_payment_form_states_field() { |
| 370 | 370 | |
| 371 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
| 371 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
| 372 | 372 | exit; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - $elements = getpaid_get_payment_form_elements( $_GET['form'] ); |
|
| 375 | + $elements = getpaid_get_payment_form_elements($_GET['form']); |
|
| 376 | 376 | |
| 377 | - if ( empty( $elements ) ) { |
|
| 377 | + if (empty($elements)) { |
|
| 378 | 378 | exit; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | $address_fields = array(); |
| 382 | - foreach ( $elements as $element ) { |
|
| 383 | - if ( 'address' === $element['type'] ) { |
|
| 382 | + foreach ($elements as $element) { |
|
| 383 | + if ('address' === $element['type']) { |
|
| 384 | 384 | $address_fields = $element; |
| 385 | 385 | break; |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - if ( empty( $address_fields ) ) { |
|
| 389 | + if (empty($address_fields)) { |
|
| 390 | 390 | exit; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
| 393 | + foreach ($address_fields['fields'] as $address_field) { |
|
| 394 | 394 | |
| 395 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
| 395 | + if ('wpinv_state' == $address_field['name']) { |
|
| 396 | 396 | |
| 397 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
| 398 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
| 399 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
| 400 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
| 401 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
| 402 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
| 397 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
| 398 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
| 399 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
| 400 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
| 401 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
| 402 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
| 403 | 403 | |
| 404 | - if ( ! empty( $address_field['required'] ) ) { |
|
| 404 | + if (!empty($address_field['required'])) { |
|
| 405 | 405 | $label .= "<span class='text-danger'> *</span>"; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $html = getpaid_get_states_select_markup ( |
|
| 409 | - sanitize_text_field( $_GET['country'] ), |
|
| 408 | + $html = getpaid_get_states_select_markup( |
|
| 409 | + sanitize_text_field($_GET['country']), |
|
| 410 | 410 | $value, |
| 411 | 411 | $placeholder, |
| 412 | 412 | $label, |
| 413 | 413 | $description, |
| 414 | - ! empty( $address_field['required'] ), |
|
| 414 | + !empty($address_field['required']), |
|
| 415 | 415 | $wrap_class, |
| 416 | - wpinv_clean( $_GET['name'] ) |
|
| 416 | + wpinv_clean($_GET['name']) |
|
| 417 | 417 | ); |
| 418 | 418 | |
| 419 | - wp_send_json_success( $html ); |
|
| 419 | + wp_send_json_success($html); |
|
| 420 | 420 | exit; |
| 421 | 421 | |
| 422 | 422 | } |
@@ -432,66 +432,66 @@ discard block |
||
| 432 | 432 | public static function recalculate_invoice_totals() { |
| 433 | 433 | |
| 434 | 434 | // Verify nonce. |
| 435 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 435 | + check_ajax_referer('wpinv-nonce'); |
|
| 436 | 436 | |
| 437 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 437 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 438 | 438 | exit; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | // We need an invoice. |
| 442 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 442 | + if (empty($_POST['post_id'])) { |
|
| 443 | 443 | exit; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | // Fetch the invoice. |
| 447 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) ); |
|
| 447 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id'])); |
|
| 448 | 448 | |
| 449 | 449 | // Ensure it exists. |
| 450 | - if ( ! $invoice->get_id() ) { |
|
| 450 | + if (!$invoice->get_id()) { |
|
| 451 | 451 | exit; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | // Maybe set the country, state, currency. |
| 455 | - foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) { |
|
| 456 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 455 | + foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) { |
|
| 456 | + if (isset($_POST[$key])) { |
|
| 457 | 457 | $method = "set_$key"; |
| 458 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
| 458 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | // Maybe disable taxes. |
| 463 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
| 463 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
| 464 | 464 | |
| 465 | 465 | // Discount code. |
| 466 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 467 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 468 | - if ( $discount->exists() ) { |
|
| 469 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 466 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 467 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
| 468 | + if ($discount->exists()) { |
|
| 469 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
| 470 | 470 | } else { |
| 471 | - $invoice->remove_discount( 'discount_code' ); |
|
| 471 | + $invoice->remove_discount('discount_code'); |
|
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | // Recalculate totals. |
| 476 | 476 | $invoice->recalculate_total(); |
| 477 | 477 | |
| 478 | - $total = wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
| 479 | - $suscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 480 | - if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
| 481 | - $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() ); |
|
| 482 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
| 478 | + $total = wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
| 479 | + $suscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 480 | + if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
| 481 | + $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency()); |
|
| 482 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | $totals = array( |
| 486 | - 'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
| 487 | - 'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
| 488 | - 'tax' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
| 486 | + 'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
| 487 | + 'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
| 488 | + 'tax' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
| 489 | 489 | 'total' => $total, |
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
| 492 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
| 493 | 493 | |
| 494 | - wp_send_json_success( compact( 'totals' ) ); |
|
| 494 | + wp_send_json_success(compact('totals')); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
@@ -500,33 +500,33 @@ discard block |
||
| 500 | 500 | public static function get_invoice_items() { |
| 501 | 501 | |
| 502 | 502 | // Verify nonce. |
| 503 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 503 | + check_ajax_referer('wpinv-nonce'); |
|
| 504 | 504 | |
| 505 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 505 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 506 | 506 | exit; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | // We need an invoice and items. |
| 510 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 510 | + if (empty($_POST['post_id'])) { |
|
| 511 | 511 | exit; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | // Fetch the invoice. |
| 515 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) ); |
|
| 515 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id'])); |
|
| 516 | 516 | |
| 517 | 517 | // Ensure it exists. |
| 518 | - if ( ! $invoice->get_id() ) { |
|
| 518 | + if (!$invoice->get_id()) { |
|
| 519 | 519 | exit; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | // Return an array of invoice items. |
| 523 | 523 | $items = array(); |
| 524 | 524 | |
| 525 | - foreach ( $invoice->get_items() as $item ) { |
|
| 526 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() ); |
|
| 525 | + foreach ($invoice->get_items() as $item) { |
|
| 526 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal()); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - wp_send_json_success( compact( 'items' ) ); |
|
| 529 | + wp_send_json_success(compact('items')); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -535,50 +535,50 @@ discard block |
||
| 535 | 535 | public static function edit_invoice_item() { |
| 536 | 536 | |
| 537 | 537 | // Verify nonce. |
| 538 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 538 | + check_ajax_referer('wpinv-nonce'); |
|
| 539 | 539 | |
| 540 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 540 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 541 | 541 | exit; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | // We need an invoice and item details. |
| 545 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
| 545 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
| 546 | 546 | exit; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | // Fetch the invoice. |
| 550 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) ); |
|
| 550 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id'])); |
|
| 551 | 551 | |
| 552 | 552 | // Ensure it exists and its not been paid for. |
| 553 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 553 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 554 | 554 | exit; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | // Format the data. |
| 558 | - $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) ); |
|
| 558 | + $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field'))); |
|
| 559 | 559 | |
| 560 | 560 | // Ensure that we have an item id. |
| 561 | - if ( empty( $data['id'] ) ) { |
|
| 561 | + if (empty($data['id'])) { |
|
| 562 | 562 | exit; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | // Abort if the invoice does not have the specified item. |
| 566 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
| 566 | + $item = $invoice->get_item((int) $data['id']); |
|
| 567 | 567 | |
| 568 | - if ( empty( $item ) ) { |
|
| 568 | + if (empty($item)) { |
|
| 569 | 569 | exit; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | // Update the item. |
| 573 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
| 574 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
| 575 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
| 576 | - $item->set_quantity( floatval( $data['quantity'] ) ); |
|
| 573 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
| 574 | + $item->set_name(sanitize_text_field($data['name'])); |
|
| 575 | + $item->set_description(wp_kses_post($data['description'])); |
|
| 576 | + $item->set_quantity(floatval($data['quantity'])); |
|
| 577 | 577 | |
| 578 | 578 | // Add it to the invoice. |
| 579 | - $error = $invoice->add_item( $item ); |
|
| 579 | + $error = $invoice->add_item($item); |
|
| 580 | 580 | $alert = false; |
| 581 | - if ( is_wp_error( $error ) ) { |
|
| 581 | + if (is_wp_error($error)) { |
|
| 582 | 582 | $alert = $error->get_error_message(); |
| 583 | 583 | } |
| 584 | 584 | |
@@ -591,11 +591,11 @@ discard block |
||
| 591 | 591 | // Return an array of invoice items. |
| 592 | 592 | $items = array(); |
| 593 | 593 | |
| 594 | - foreach ( $invoice->get_items() as $item ) { |
|
| 595 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 594 | + foreach ($invoice->get_items() as $item) { |
|
| 595 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
| 598 | + wp_send_json_success(compact('items', 'alert')); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
@@ -604,53 +604,53 @@ discard block |
||
| 604 | 604 | public static function create_invoice_item() { |
| 605 | 605 | |
| 606 | 606 | // Verify nonce. |
| 607 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 607 | + check_ajax_referer('wpinv-nonce'); |
|
| 608 | 608 | |
| 609 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 609 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 610 | 610 | exit; |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | // We need an invoice and item details. |
| 614 | - if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) { |
|
| 614 | + if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) { |
|
| 615 | 615 | exit; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | // Fetch the invoice. |
| 619 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['invoice_id'] ) ); |
|
| 619 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['invoice_id'])); |
|
| 620 | 620 | |
| 621 | 621 | // Ensure it exists and its not been paid for. |
| 622 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 622 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 623 | 623 | exit; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | // Format the data. |
| 627 | - $data = wp_unslash( $_POST['_wpinv_quick'] ); |
|
| 627 | + $data = wp_unslash($_POST['_wpinv_quick']); |
|
| 628 | 628 | |
| 629 | 629 | $item = new WPInv_Item(); |
| 630 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
| 631 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
| 632 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
| 633 | - $item->set_type( sanitize_text_field( $data['type'] ) ); |
|
| 634 | - $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) ); |
|
| 635 | - $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) ); |
|
| 636 | - $item->set_status( 'publish' ); |
|
| 630 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
| 631 | + $item->set_name(sanitize_text_field($data['name'])); |
|
| 632 | + $item->set_description(wp_kses_post($data['description'])); |
|
| 633 | + $item->set_type(sanitize_text_field($data['type'])); |
|
| 634 | + $item->set_vat_rule(sanitize_text_field($data['vat_rule'])); |
|
| 635 | + $item->set_vat_class(sanitize_text_field($data['vat_class'])); |
|
| 636 | + $item->set_status('publish'); |
|
| 637 | 637 | $item->save(); |
| 638 | 638 | |
| 639 | - if ( ! $item->exists() ) { |
|
| 640 | - $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' ); |
|
| 641 | - wp_send_json_success( compact( 'alert' ) ); |
|
| 639 | + if (!$item->exists()) { |
|
| 640 | + $alert = __('Could not create invoice item. Please try again.', 'invoicing'); |
|
| 641 | + wp_send_json_success(compact('alert')); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - $item = new GetPaid_Form_Item( $item->get_id() ); |
|
| 645 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
| 644 | + $item = new GetPaid_Form_Item($item->get_id()); |
|
| 645 | + $item->set_quantity(floatval($data['qty'])); |
|
| 646 | 646 | |
| 647 | 647 | // Add it to the invoice. |
| 648 | - $error = $invoice->add_item( $item ); |
|
| 648 | + $error = $invoice->add_item($item); |
|
| 649 | 649 | $alert = false; |
| 650 | 650 | |
| 651 | - if ( is_wp_error( $error ) ) { |
|
| 651 | + if (is_wp_error($error)) { |
|
| 652 | 652 | $alert = $error->get_error_message(); |
| 653 | - wp_send_json_success( compact( 'alert' ) ); |
|
| 653 | + wp_send_json_success(compact('alert')); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | // Update totals. |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | $invoice->recalculate_total(); |
| 664 | 664 | $invoice->save(); |
| 665 | 665 | ob_start(); |
| 666 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
| 666 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
| 667 | 667 | $row = ob_get_clean(); |
| 668 | - wp_send_json_success( compact( 'row' ) ); |
|
| 668 | + wp_send_json_success(compact('row')); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | /** |
@@ -674,33 +674,33 @@ discard block |
||
| 674 | 674 | public static function remove_invoice_item() { |
| 675 | 675 | |
| 676 | 676 | // Verify nonce. |
| 677 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 677 | + check_ajax_referer('wpinv-nonce'); |
|
| 678 | 678 | |
| 679 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 679 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 680 | 680 | exit; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | // We need an invoice and an item. |
| 684 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
| 684 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
| 685 | 685 | exit; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | // Fetch the invoice. |
| 689 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) ); |
|
| 689 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id'])); |
|
| 690 | 690 | |
| 691 | 691 | // Ensure it exists and its not been paid for. |
| 692 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 692 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 693 | 693 | exit; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | // Abort if the invoice does not have the specified item. |
| 697 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
| 697 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
| 698 | 698 | |
| 699 | - if ( empty( $item ) ) { |
|
| 699 | + if (empty($item)) { |
|
| 700 | 700 | exit; |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
| 703 | + $invoice->remove_item((int) $_POST['item_id']); |
|
| 704 | 704 | |
| 705 | 705 | // Update totals. |
| 706 | 706 | $invoice->recalculate_total(); |
@@ -711,11 +711,11 @@ discard block |
||
| 711 | 711 | // Return an array of invoice items. |
| 712 | 712 | $items = array(); |
| 713 | 713 | |
| 714 | - foreach ( $invoice->get_items() as $item ) { |
|
| 715 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 714 | + foreach ($invoice->get_items() as $item) { |
|
| 715 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - wp_send_json_success( compact( 'items' ) ); |
|
| 718 | + wp_send_json_success(compact('items')); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
@@ -724,69 +724,69 @@ discard block |
||
| 724 | 724 | public static function recalculate_full_prices() { |
| 725 | 725 | |
| 726 | 726 | // Verify nonce. |
| 727 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 727 | + check_ajax_referer('wpinv-nonce'); |
|
| 728 | 728 | |
| 729 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 729 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 730 | 730 | exit; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | // We need an invoice and item. |
| 734 | - if ( empty( $_POST['post_id'] ) ) { |
|
| 734 | + if (empty($_POST['post_id'])) { |
|
| 735 | 735 | exit; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | // Fetch the invoice. |
| 739 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) ); |
|
| 739 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id'])); |
|
| 740 | 740 | $alert = false; |
| 741 | 741 | |
| 742 | 742 | // Ensure it exists and its not been paid for. |
| 743 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 743 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 744 | 744 | exit; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - $invoice->set_items( array() ); |
|
| 747 | + $invoice->set_items(array()); |
|
| 748 | 748 | |
| 749 | - if ( ! empty( $_POST['getpaid_items'] ) ) { |
|
| 749 | + if (!empty($_POST['getpaid_items'])) { |
|
| 750 | 750 | |
| 751 | - foreach ( $_POST['getpaid_items'] as $item_id => $args ) { |
|
| 752 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 751 | + foreach ($_POST['getpaid_items'] as $item_id => $args) { |
|
| 752 | + $item = new GetPaid_Form_Item($item_id); |
|
| 753 | 753 | |
| 754 | - if ( $item->exists() ) { |
|
| 755 | - $item->set_price( getpaid_standardize_amount( $args['price'] ) ); |
|
| 756 | - $item->set_quantity( floatval( $args['quantity'] ) ); |
|
| 757 | - $item->set_name( sanitize_text_field( $args['name'] ) ); |
|
| 758 | - $item->set_description( wp_kses_post( $args['description'] ) ); |
|
| 759 | - $invoice->add_item( $item ); |
|
| 754 | + if ($item->exists()) { |
|
| 755 | + $item->set_price(getpaid_standardize_amount($args['price'])); |
|
| 756 | + $item->set_quantity(floatval($args['quantity'])); |
|
| 757 | + $item->set_name(sanitize_text_field($args['name'])); |
|
| 758 | + $item->set_description(wp_kses_post($args['description'])); |
|
| 759 | + $invoice->add_item($item); |
|
| 760 | 760 | } |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) ); |
|
| 765 | + $invoice->set_disable_taxes(!empty($_POST['disable_taxes'])); |
|
| 766 | 766 | |
| 767 | 767 | // Maybe set the country, state, currency. |
| 768 | - foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) { |
|
| 769 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 770 | - $_key = str_replace( 'wpinv_', '', $key ); |
|
| 768 | + foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) { |
|
| 769 | + if (isset($_POST[$key])) { |
|
| 770 | + $_key = str_replace('wpinv_', '', $key); |
|
| 771 | 771 | $method = "set_$_key"; |
| 772 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
| 772 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 777 | - if ( $discount->exists() ) { |
|
| 778 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 776 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
| 777 | + if ($discount->exists()) { |
|
| 778 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
| 779 | 779 | } else { |
| 780 | - $invoice->remove_discount( 'discount_code' ); |
|
| 780 | + $invoice->remove_discount('discount_code'); |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | // Save the invoice. |
| 784 | 784 | $invoice->recalculate_total(); |
| 785 | 785 | $invoice->save(); |
| 786 | 786 | ob_start(); |
| 787 | - GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice ); |
|
| 787 | + GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice); |
|
| 788 | 788 | $table = ob_get_clean(); |
| 789 | - wp_send_json_success( compact( 'table' ) ); |
|
| 789 | + wp_send_json_success(compact('table')); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | /** |
@@ -795,42 +795,42 @@ discard block |
||
| 795 | 795 | public static function admin_add_invoice_item() { |
| 796 | 796 | |
| 797 | 797 | // Verify nonce. |
| 798 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 798 | + check_ajax_referer('wpinv-nonce'); |
|
| 799 | 799 | |
| 800 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 800 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 801 | 801 | exit; |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | // We need an invoice and item. |
| 805 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
| 805 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
| 806 | 806 | exit; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | // Fetch the invoice. |
| 810 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) ); |
|
| 810 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id'])); |
|
| 811 | 811 | $alert = false; |
| 812 | 812 | |
| 813 | 813 | // Ensure it exists and its not been paid for. |
| 814 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 814 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 815 | 815 | exit; |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | // Add the item. |
| 819 | - $item = new GetPaid_Form_Item( (int) $_POST['item_id'] ); |
|
| 820 | - $error = $invoice->add_item( $item ); |
|
| 819 | + $item = new GetPaid_Form_Item((int) $_POST['item_id']); |
|
| 820 | + $error = $invoice->add_item($item); |
|
| 821 | 821 | |
| 822 | - if ( is_wp_error( $error ) ) { |
|
| 822 | + if (is_wp_error($error)) { |
|
| 823 | 823 | $alert = $error->get_error_message(); |
| 824 | - wp_send_json_success( compact( 'alert' ) ); |
|
| 824 | + wp_send_json_success(compact('alert')); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | // Save the invoice. |
| 828 | 828 | $invoice->recalculate_total(); |
| 829 | 829 | $invoice->save(); |
| 830 | 830 | ob_start(); |
| 831 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
| 831 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
| 832 | 832 | $row = ob_get_clean(); |
| 833 | - wp_send_json_success( compact( 'row' ) ); |
|
| 833 | + wp_send_json_success(compact('row')); |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /** |
@@ -839,39 +839,39 @@ discard block |
||
| 839 | 839 | public static function add_invoice_items() { |
| 840 | 840 | |
| 841 | 841 | // Verify nonce. |
| 842 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 842 | + check_ajax_referer('wpinv-nonce'); |
|
| 843 | 843 | |
| 844 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 844 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 845 | 845 | exit; |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | // We need an invoice and items. |
| 849 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
| 849 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
| 850 | 850 | exit; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | // Fetch the invoice. |
| 854 | - $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) ); |
|
| 854 | + $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id'])); |
|
| 855 | 855 | $alert = false; |
| 856 | 856 | |
| 857 | 857 | // Ensure it exists and its not been paid for. |
| 858 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 858 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 859 | 859 | exit; |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | // Add the items. |
| 863 | - foreach ( $_POST['items'] as $data ) { |
|
| 863 | + foreach ($_POST['items'] as $data) { |
|
| 864 | 864 | |
| 865 | - $item = new GetPaid_Form_Item( (int) $data[ 'id' ] ); |
|
| 865 | + $item = new GetPaid_Form_Item((int) $data['id']); |
|
| 866 | 866 | |
| 867 | - if ( is_numeric( $data[ 'qty' ] ) && (float) $data[ 'qty' ] > 0 ) { |
|
| 868 | - $item->set_quantity( floatval( $data[ 'qty' ] ) ); |
|
| 867 | + if (is_numeric($data['qty']) && (float) $data['qty'] > 0) { |
|
| 868 | + $item->set_quantity(floatval($data['qty'])); |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( $item->get_id() > 0 ) { |
|
| 872 | - $error = $invoice->add_item( $item ); |
|
| 871 | + if ($item->get_id() > 0) { |
|
| 872 | + $error = $invoice->add_item($item); |
|
| 873 | 873 | |
| 874 | - if ( is_wp_error( $error ) ) { |
|
| 874 | + if (is_wp_error($error)) { |
|
| 875 | 875 | $alert = $error->get_error_message(); |
| 876 | 876 | } |
| 877 | 877 | |
@@ -886,11 +886,11 @@ discard block |
||
| 886 | 886 | // Return an array of invoice items. |
| 887 | 887 | $items = array(); |
| 888 | 888 | |
| 889 | - foreach ( $invoice->get_items() as $item ) { |
|
| 890 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
| 889 | + foreach ($invoice->get_items() as $item) { |
|
| 890 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
| 893 | + wp_send_json_success(compact('items', 'alert')); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | /** |
@@ -899,15 +899,15 @@ discard block |
||
| 899 | 899 | public static function get_invoicing_items() { |
| 900 | 900 | |
| 901 | 901 | // Verify nonce. |
| 902 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 902 | + check_ajax_referer('wpinv-nonce'); |
|
| 903 | 903 | |
| 904 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 904 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 905 | 905 | exit; |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | // We need a search term. |
| 909 | - if ( empty( $_GET['search'] ) ) { |
|
| 910 | - wp_send_json_success( array() ); |
|
| 909 | + if (empty($_GET['search'])) { |
|
| 910 | + wp_send_json_success(array()); |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | // Retrieve items. |
@@ -916,8 +916,8 @@ discard block |
||
| 916 | 916 | 'orderby' => 'title', |
| 917 | 917 | 'order' => 'ASC', |
| 918 | 918 | 'posts_per_page' => -1, |
| 919 | - 'post_status' => array( 'publish' ), |
|
| 920 | - 's' => trim( $_GET['search'] ), |
|
| 919 | + 'post_status' => array('publish'), |
|
| 920 | + 's' => trim($_GET['search']), |
|
| 921 | 921 | 'meta_query' => array( |
| 922 | 922 | array( |
| 923 | 923 | 'key' => '_wpinv_type', |
@@ -927,21 +927,21 @@ discard block |
||
| 927 | 927 | ) |
| 928 | 928 | ); |
| 929 | 929 | |
| 930 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
| 930 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
| 931 | 931 | $data = array(); |
| 932 | 932 | |
| 933 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) ); |
|
| 933 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id'])); |
|
| 934 | 934 | |
| 935 | - foreach ( $items as $item ) { |
|
| 936 | - $item = new GetPaid_Form_Item( $item ); |
|
| 935 | + foreach ($items as $item) { |
|
| 936 | + $item = new GetPaid_Form_Item($item); |
|
| 937 | 937 | $data[] = array( |
| 938 | 938 | 'id' => (int) $item->get_id(), |
| 939 | - 'text' => strip_tags( $item->get_name() ), |
|
| 940 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
| 939 | + 'text' => strip_tags($item->get_name()), |
|
| 940 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
| 941 | 941 | ); |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | - wp_send_json_success( $data ); |
|
| 944 | + wp_send_json_success($data); |
|
| 945 | 945 | |
| 946 | 946 | } |
| 947 | 947 | |
@@ -951,37 +951,37 @@ discard block |
||
| 951 | 951 | public static function get_customers() { |
| 952 | 952 | |
| 953 | 953 | // Verify nonce. |
| 954 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 954 | + check_ajax_referer('wpinv-nonce'); |
|
| 955 | 955 | |
| 956 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 956 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 957 | 957 | exit; |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | // We need a search term. |
| 961 | - if ( empty( $_GET['search'] ) ) { |
|
| 962 | - wp_send_json_success( array() ); |
|
| 961 | + if (empty($_GET['search'])) { |
|
| 962 | + wp_send_json_success(array()); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | // Retrieve customers. |
| 966 | 966 | |
| 967 | 967 | $customer_args = array( |
| 968 | - 'fields' => array( 'ID', 'user_email', 'display_name' ), |
|
| 968 | + 'fields' => array('ID', 'user_email', 'display_name'), |
|
| 969 | 969 | 'orderby' => 'display_name', |
| 970 | - 'search' => '*' . sanitize_text_field( $_GET['search'] ) . '*', |
|
| 971 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
| 970 | + 'search' => '*' . sanitize_text_field($_GET['search']) . '*', |
|
| 971 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
| 972 | 972 | ); |
| 973 | 973 | |
| 974 | - $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) ); |
|
| 974 | + $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args)); |
|
| 975 | 975 | $data = array(); |
| 976 | 976 | |
| 977 | - foreach ( $customers as $customer ) { |
|
| 977 | + foreach ($customers as $customer) { |
|
| 978 | 978 | $data[] = array( |
| 979 | 979 | 'id' => (int) $customer->ID, |
| 980 | - 'text' => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ), |
|
| 980 | + 'text' => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)), |
|
| 981 | 981 | ); |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - wp_send_json_success( $data ); |
|
| 984 | + wp_send_json_success($data); |
|
| 985 | 985 | |
| 986 | 986 | } |
| 987 | 987 | |
@@ -991,28 +991,28 @@ discard block |
||
| 991 | 991 | public static function get_aui_states_field() { |
| 992 | 992 | |
| 993 | 993 | // Verify nonce. |
| 994 | - check_ajax_referer( 'wpinv-nonce' ); |
|
| 994 | + check_ajax_referer('wpinv-nonce'); |
|
| 995 | 995 | |
| 996 | 996 | // We need a country. |
| 997 | - if ( empty( $_GET['country'] ) ) { |
|
| 997 | + if (empty($_GET['country'])) { |
|
| 998 | 998 | exit; |
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | - $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) ); |
|
| 1002 | - $state = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state(); |
|
| 1003 | - $name = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state'; |
|
| 1004 | - $class = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm'; |
|
| 1001 | + $states = wpinv_get_country_states(sanitize_text_field($_GET['country'])); |
|
| 1002 | + $state = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state(); |
|
| 1003 | + $name = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state'; |
|
| 1004 | + $class = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm'; |
|
| 1005 | 1005 | |
| 1006 | - if ( empty( $states ) ) { |
|
| 1006 | + if (empty($states)) { |
|
| 1007 | 1007 | |
| 1008 | 1008 | $html = aui()->input( |
| 1009 | 1009 | array( |
| 1010 | 1010 | 'type' => 'text', |
| 1011 | 1011 | 'id' => 'wpinv_state', |
| 1012 | 1012 | 'name' => $name, |
| 1013 | - 'label' => __( 'State', 'invoicing' ), |
|
| 1013 | + 'label' => __('State', 'invoicing'), |
|
| 1014 | 1014 | 'label_type' => 'vertical', |
| 1015 | - 'placeholder' => __( 'State', 'invoicing' ), |
|
| 1015 | + 'placeholder' => __('State', 'invoicing'), |
|
| 1016 | 1016 | 'class' => $class, |
| 1017 | 1017 | 'value' => $state, |
| 1018 | 1018 | ) |
@@ -1024,9 +1024,9 @@ discard block |
||
| 1024 | 1024 | array( |
| 1025 | 1025 | 'id' => 'wpinv_state', |
| 1026 | 1026 | 'name' => $name, |
| 1027 | - 'label' => __( 'State', 'invoicing' ), |
|
| 1027 | + 'label' => __('State', 'invoicing'), |
|
| 1028 | 1028 | 'label_type' => 'vertical', |
| 1029 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 1029 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 1030 | 1030 | 'class' => $class, |
| 1031 | 1031 | 'value' => $state, |
| 1032 | 1032 | 'options' => $states, |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | wp_send_json_success( |
| 1041 | 1041 | array( |
| 1042 | 1042 | 'html' => $html, |
| 1043 | - 'select' => ! empty ( $states ) |
|
| 1043 | + 'select' => !empty ($states) |
|
| 1044 | 1044 | ) |
| 1045 | 1045 | ); |
| 1046 | 1046 | |
@@ -1054,11 +1054,11 @@ discard block |
||
| 1054 | 1054 | public static function payment_form_refresh_prices() { |
| 1055 | 1055 | |
| 1056 | 1056 | // Check nonce. |
| 1057 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 1057 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 1058 | 1058 | |
| 1059 | 1059 | // ... form fields... |
| 1060 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
| 1061 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
| 1060 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
| 1061 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
| 1062 | 1062 | exit; |
| 1063 | 1063 | } |
| 1064 | 1064 | |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | $submission = new GetPaid_Payment_Form_Submission(); |
| 1067 | 1067 | |
| 1068 | 1068 | // Do we have an error? |
| 1069 | - if ( ! empty( $submission->last_error ) ) { |
|
| 1069 | + if (!empty($submission->last_error)) { |
|
| 1070 | 1070 | wp_send_json_error( |
| 1071 | 1071 | array( |
| 1072 | 1072 | 'code' => $submission->last_error_code, |
@@ -1076,12 +1076,12 @@ discard block |
||
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | // Prepare the response. |
| 1079 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
| 1079 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
| 1080 | 1080 | |
| 1081 | 1081 | // Filter the response. |
| 1082 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
| 1082 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
| 1083 | 1083 | |
| 1084 | - wp_send_json_success( $response ); |
|
| 1084 | + wp_send_json_success($response); |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | /** |
@@ -1093,63 +1093,63 @@ discard block |
||
| 1093 | 1093 | public static function file_upload() { |
| 1094 | 1094 | |
| 1095 | 1095 | // Check nonce. |
| 1096 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
| 1096 | + check_ajax_referer('getpaid_form_nonce'); |
|
| 1097 | 1097 | |
| 1098 | - if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) { |
|
| 1099 | - wp_die( __( 'Bad Request', 'invoicing' ), 400 ); |
|
| 1098 | + if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) { |
|
| 1099 | + wp_die(__('Bad Request', 'invoicing'), 400); |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | // Fetch form. |
| 1103 | - $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) ); |
|
| 1103 | + $form = new GetPaid_Payment_Form(intval($_POST['form_id'])); |
|
| 1104 | 1104 | |
| 1105 | - if ( ! $form->is_active() ) { |
|
| 1106 | - wp_send_json_error( __( 'Payment form not active', 'invoicing' ) ); |
|
| 1105 | + if (!$form->is_active()) { |
|
| 1106 | + wp_send_json_error(__('Payment form not active', 'invoicing')); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | // Fetch appropriate field. |
| 1110 | - $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) ); |
|
| 1111 | - if ( empty( $upload_field ) ) { |
|
| 1112 | - wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) ); |
|
| 1110 | + $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name'])))); |
|
| 1111 | + if (empty($upload_field)) { |
|
| 1112 | + wp_send_json_error(__('Invalid upload field.', 'invoicing')); |
|
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | // Prepare allowed file types. |
| 1116 | - $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' ); |
|
| 1116 | + $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png'); |
|
| 1117 | 1117 | $all_types = getpaid_get_allowed_mime_types(); |
| 1118 | 1118 | $mime_types = array(); |
| 1119 | 1119 | |
| 1120 | - foreach ( $file_types as $file_type ) { |
|
| 1121 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
| 1122 | - $mime_types[] = $all_types[ $file_type ]; |
|
| 1120 | + foreach ($file_types as $file_type) { |
|
| 1121 | + if (isset($all_types[$file_type])) { |
|
| 1122 | + $mime_types[] = $all_types[$file_type]; |
|
| 1123 | 1123 | } |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | - if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) { |
|
| 1127 | - wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) ); |
|
| 1126 | + if (!in_array($_FILES['file']['type'], $mime_types)) { |
|
| 1127 | + wp_send_json_error(__('Unsupported file type.', 'invoicing')); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | 1130 | // Upload file. |
| 1131 | - $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) ); |
|
| 1132 | - $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name ); |
|
| 1131 | + $file_name = explode('.', strtolower($_FILES['file']['name'])); |
|
| 1132 | + $file_name = uniqid('getpaid-') . '.' . array_pop($file_name); |
|
| 1133 | 1133 | |
| 1134 | 1134 | $uploaded = wp_upload_bits( |
| 1135 | 1135 | $file_name, |
| 1136 | 1136 | null, |
| 1137 | - file_get_contents( $_FILES["file"]["tmp_name"] ) |
|
| 1137 | + file_get_contents($_FILES["file"]["tmp_name"]) |
|
| 1138 | 1138 | ); |
| 1139 | 1139 | |
| 1140 | - if ( ! empty( $uploaded['error'] ) ) { |
|
| 1141 | - wp_send_json_error( $uploaded['error'] ); |
|
| 1140 | + if (!empty($uploaded['error'])) { |
|
| 1141 | + wp_send_json_error($uploaded['error']); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | // Retrieve response. |
| 1145 | 1145 | $response = sprintf( |
| 1146 | 1146 | '<input type="hidden" name="%s[%s]" value="%s" />', |
| 1147 | - esc_attr( $_POST['field_name'] ), |
|
| 1148 | - esc_attr( $uploaded['url'] ), |
|
| 1149 | - esc_attr( strtolower( $_FILES['file']['name'] ) ) |
|
| 1147 | + esc_attr($_POST['field_name']), |
|
| 1148 | + esc_attr($uploaded['url']), |
|
| 1149 | + esc_attr(strtolower($_FILES['file']['name'])) |
|
| 1150 | 1150 | ); |
| 1151 | 1151 | |
| 1152 | - wp_send_json_success( $response ); |
|
| 1152 | + wp_send_json_success($response); |
|
| 1153 | 1153 | |
| 1154 | 1154 | } |
| 1155 | 1155 | |
@@ -1,7 +1,7 @@ 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_Payment_Form { |
@@ -11,23 +11,23 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @param WP_Post $post |
| 13 | 13 | */ |
| 14 | - public static function output_details( $post ) { |
|
| 15 | - $details = get_post_meta( $post->ID, 'payment_form_data', true ); |
|
| 14 | + public static function output_details($post) { |
|
| 15 | + $details = get_post_meta($post->ID, 'payment_form_data', true); |
|
| 16 | 16 | |
| 17 | - if ( ! is_array( $details ) ) { |
|
| 17 | + if (!is_array($details)) { |
|
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | echo '<div class="bsui"> <div class="form-row">'; |
| 22 | 22 | |
| 23 | - foreach ( $details as $key => $value ) { |
|
| 24 | - $key = esc_html( $key ); |
|
| 23 | + foreach ($details as $key => $value) { |
|
| 24 | + $key = esc_html($key); |
|
| 25 | 25 | |
| 26 | - if ( is_array( $value ) ) { |
|
| 27 | - $value = implode( ',', $value ); |
|
| 26 | + if (is_array($value)) { |
|
| 27 | + $value = implode(',', $value); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $value = wp_kses_post( $value ); |
|
| 30 | + $value = wp_kses_post($value); |
|
| 31 | 31 | echo "<div class='col-12'><strong>$key:</strong></div><div class='col-12 form-group'>$value</div>"; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param WP_Post $post |
| 42 | 42 | */ |
| 43 | - public static function output_shortcode( $post ) { |
|
| 43 | + public static function output_shortcode($post) { |
|
| 44 | 44 | |
| 45 | - if ( ! is_numeric( $post ) ) { |
|
| 45 | + if (!is_numeric($post)) { |
|
| 46 | 46 | $post = $post->ID; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if ( $post == wpinv_get_default_payment_form() ) { |
|
| 49 | + if ($post == wpinv_get_default_payment_form()) { |
|
| 50 | 50 | echo '—'; |
| 51 | 51 | return; |
| 52 | 52 | } |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
| 138 | 138 | |
| 139 | - $invoice_statuses = array( |
|
| 140 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
| 139 | + $invoice_statuses = array( |
|
| 140 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
| 141 | 141 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
| 142 | 142 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
| 143 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
| 144 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 145 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 143 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
| 144 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 145 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 146 | 146 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
| 147 | 147 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
| 148 | 148 | ); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $invoice = $invoice->get_post_type(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 162 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -277,25 +277,25 @@ discard block |
||
| 277 | 277 | * @return string |
| 278 | 278 | */ |
| 279 | 279 | function getpaid_get_price_format() { |
| 280 | - $currency_pos = wpinv_currency_position(); |
|
| 281 | - $format = '%1$s%2$s'; |
|
| 282 | - |
|
| 283 | - switch ( $currency_pos ) { |
|
| 284 | - case 'left': |
|
| 285 | - $format = '%1$s%2$s'; |
|
| 286 | - break; |
|
| 287 | - case 'right': |
|
| 288 | - $format = '%2$s%1$s'; |
|
| 289 | - break; |
|
| 290 | - case 'left_space': |
|
| 291 | - $format = '%1$s %2$s'; |
|
| 292 | - break; |
|
| 293 | - case 'right_space': |
|
| 294 | - $format = '%2$s %1$s'; |
|
| 295 | - break; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
| 280 | + $currency_pos = wpinv_currency_position(); |
|
| 281 | + $format = '%1$s%2$s'; |
|
| 282 | + |
|
| 283 | + switch ( $currency_pos ) { |
|
| 284 | + case 'left': |
|
| 285 | + $format = '%1$s%2$s'; |
|
| 286 | + break; |
|
| 287 | + case 'right': |
|
| 288 | + $format = '%2$s%1$s'; |
|
| 289 | + break; |
|
| 290 | + case 'left_space': |
|
| 291 | + $format = '%1$s %2$s'; |
|
| 292 | + break; |
|
| 293 | + case 'right_space': |
|
| 294 | + $format = '%2$s %1$s'; |
|
| 295 | + break; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -390,13 +390,13 @@ discard block |
||
| 390 | 390 | * @param mixed $value Value. |
| 391 | 391 | */ |
| 392 | 392 | function getpaid_maybe_define_constant( $name, $value ) { |
| 393 | - if ( ! defined( $name ) ) { |
|
| 394 | - define( $name, $value ); |
|
| 395 | - } |
|
| 393 | + if ( ! defined( $name ) ) { |
|
| 394 | + define( $name, $value ); |
|
| 395 | + } |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function wpinv_get_php_arg_separator_output() { |
| 399 | - return ini_get( 'arg_separator.output' ); |
|
| 399 | + return ini_get( 'arg_separator.output' ); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | function wpinv_rgb_from_hex( $color ) { |
@@ -751,11 +751,11 @@ discard block |
||
| 751 | 751 | $list = array(); |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if ( ! is_array( $list ) ) { |
|
| 755 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 756 | - } |
|
| 754 | + if ( ! is_array( $list ) ) { |
|
| 755 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | - return $list; |
|
| 758 | + return $list; |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /** |
@@ -775,9 +775,9 @@ discard block |
||
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
| 778 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
| 778 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
| 779 | 779 | |
| 780 | - return $data; |
|
| 780 | + return $data; |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | /** |
@@ -806,17 +806,17 @@ discard block |
||
| 806 | 806 | */ |
| 807 | 807 | function wpinv_clean( $var ) { |
| 808 | 808 | |
| 809 | - if ( is_array( $var ) ) { |
|
| 810 | - return array_map( 'wpinv_clean', $var ); |
|
| 809 | + if ( is_array( $var ) ) { |
|
| 810 | + return array_map( 'wpinv_clean', $var ); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | if ( is_object( $var ) ) { |
| 814 | - $object_vars = get_object_vars( $var ); |
|
| 815 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 816 | - $var->$property_name = wpinv_clean( $property_value ); |
|
| 814 | + $object_vars = get_object_vars( $var ); |
|
| 815 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
| 816 | + $var->$property_name = wpinv_clean( $property_value ); |
|
| 817 | 817 | } |
| 818 | 818 | return $var; |
| 819 | - } |
|
| 819 | + } |
|
| 820 | 820 | |
| 821 | 821 | return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
| 822 | 822 | } |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | */ |
| 830 | 830 | function getpaid_convert_price_string_to_options( $str ) { |
| 831 | 831 | |
| 832 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 832 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 833 | 833 | $options = array(); |
| 834 | 834 | |
| 835 | 835 | foreach ( $raw_options as $option ) { |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | * @return string |
| 913 | 913 | */ |
| 914 | 914 | function getpaid_date_format() { |
| 915 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
| 915 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | /** |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @return string |
| 922 | 922 | */ |
| 923 | 923 | function getpaid_time_format() { |
| 924 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
| 924 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
@@ -934,15 +934,15 @@ discard block |
||
| 934 | 934 | function getpaid_limit_length( $string, $limit ) { |
| 935 | 935 | $str_limit = $limit - 3; |
| 936 | 936 | |
| 937 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 938 | - if ( mb_strlen( $string ) > $limit ) { |
|
| 939 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
| 940 | - } |
|
| 941 | - } else { |
|
| 942 | - if ( strlen( $string ) > $limit ) { |
|
| 943 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
| 944 | - } |
|
| 945 | - } |
|
| 937 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 938 | + if ( mb_strlen( $string ) > $limit ) { |
|
| 939 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
| 940 | + } |
|
| 941 | + } else { |
|
| 942 | + if ( strlen( $string ) > $limit ) { |
|
| 943 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
| 944 | + } |
|
| 945 | + } |
|
| 946 | 946 | return $string; |
| 947 | 947 | |
| 948 | 948 | } |
@@ -1073,12 +1073,12 @@ discard block |
||
| 1073 | 1073 | $types = get_allowed_mime_types(); |
| 1074 | 1074 | |
| 1075 | 1075 | if ( isset( $types['htm|html'] ) ) { |
| 1076 | - unset( $types['htm|html'] ); |
|
| 1077 | - } |
|
| 1076 | + unset( $types['htm|html'] ); |
|
| 1077 | + } |
|
| 1078 | 1078 | |
| 1079 | 1079 | if ( isset( $types['js'] ) ) { |
| 1080 | - unset( $types['js'] ); |
|
| 1081 | - } |
|
| 1080 | + unset( $types['js'] ); |
|
| 1081 | + } |
|
| 1082 | 1082 | |
| 1083 | 1083 | return $types; |
| 1084 | 1084 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Are we supporting item quantities? |
@@ -20,35 +20,35 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | function wpinv_get_ip() { |
| 22 | 22 | |
| 23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
| 24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
| 23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
| 24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
| 29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
| 30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
| 30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
| 33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
| 37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
| 38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return ''; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | function wpinv_get_user_agent() { |
| 45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
| 45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
| 47 | 47 | } else { |
| 48 | 48 | $user_agent = ''; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
| 51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | * @param string $amount The amount to sanitize. |
| 58 | 58 | * @return float |
| 59 | 59 | */ |
| 60 | -function getpaid_standardize_amount( $amount ) { |
|
| 60 | +function getpaid_standardize_amount($amount) { |
|
| 61 | 61 | |
| 62 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
| 63 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
| 64 | - if ( is_numeric( $amount ) ) { |
|
| 65 | - return floatval( $amount ); |
|
| 62 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
| 63 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
| 64 | + if (is_numeric($amount)) { |
|
| 65 | + return floatval($amount); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Cast the remaining to a float. |
| 69 | - return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) ); |
|
| 69 | + return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount)); |
|
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @param string $amount The amount to sanitize. |
| 77 | 77 | */ |
| 78 | -function getpaid_unstandardize_amount( $amount ) { |
|
| 79 | - return str_replace( '.', wpinv_decimal_separator(), $amount ); |
|
| 78 | +function getpaid_unstandardize_amount($amount) { |
|
| 79 | + return str_replace('.', wpinv_decimal_separator(), $amount); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -84,23 +84,23 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @param string $amount The amount to sanitize. |
| 86 | 86 | */ |
| 87 | -function wpinv_sanitize_amount( $amount ) { |
|
| 87 | +function wpinv_sanitize_amount($amount) { |
|
| 88 | 88 | |
| 89 | - if ( is_numeric( $amount ) ) { |
|
| 90 | - return floatval( $amount ); |
|
| 89 | + if (is_numeric($amount)) { |
|
| 90 | + return floatval($amount); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Separate the decimals and thousands. |
| 94 | - $amount = explode( wpinv_decimal_separator(), $amount ); |
|
| 94 | + $amount = explode(wpinv_decimal_separator(), $amount); |
|
| 95 | 95 | |
| 96 | 96 | // Remove thousands. |
| 97 | - $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] ); |
|
| 97 | + $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]); |
|
| 98 | 98 | |
| 99 | 99 | // Convert back to string. |
| 100 | - $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
| 100 | + $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
| 101 | 101 | |
| 102 | 102 | // Cast the remaining to a float. |
| 103 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
| 103 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
@@ -110,19 +110,19 @@ discard block |
||
| 110 | 110 | * @param float $amount |
| 111 | 111 | * @param float|string|int|null $decimals |
| 112 | 112 | */ |
| 113 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
| 113 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
| 114 | 114 | |
| 115 | - if ( $decimals === null ) { |
|
| 115 | + if ($decimals === null) { |
|
| 116 | 116 | $decimals = wpinv_decimals(); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( $use_sprintf ) { |
|
| 120 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
| 119 | + if ($use_sprintf) { |
|
| 120 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
| 121 | 121 | } else { |
| 122 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
| 122 | + $amount = round((float) $amount, absint($decimals)); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
| 125 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -134,32 +134,32 @@ discard block |
||
| 134 | 134 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
| 135 | 135 | * @return array |
| 136 | 136 | */ |
| 137 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
| 137 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
| 138 | 138 | |
| 139 | 139 | $invoice_statuses = array( |
| 140 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
| 141 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
| 142 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 143 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
| 144 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 145 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 146 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 147 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
| 140 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
| 141 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
| 142 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
| 143 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
| 144 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
| 145 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
| 146 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
| 147 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | - if ( $draft ) { |
|
| 151 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
| 150 | + if ($draft) { |
|
| 151 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ( $trashed ) { |
|
| 155 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
| 154 | + if ($trashed) { |
|
| 155 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
| 158 | + if ($invoice instanceof WPInv_Invoice) { |
|
| 159 | 159 | $invoice = $invoice->get_post_type(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
| 162 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | * @param string $status The raw status |
| 169 | 169 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
| 170 | 170 | */ |
| 171 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
| 172 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
| 173 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : $status; |
|
| 171 | +function wpinv_status_nicename($status, $invoice = false) { |
|
| 172 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
| 173 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
| 174 | 174 | |
| 175 | - return sanitize_text_field( $status ); |
|
| 175 | + return sanitize_text_field($status); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @param string $current |
| 182 | 182 | */ |
| 183 | -function wpinv_get_currency( $current = '' ) { |
|
| 183 | +function wpinv_get_currency($current = '') { |
|
| 184 | 184 | |
| 185 | - if ( empty( $current ) ) { |
|
| 186 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
| 185 | + if (empty($current)) { |
|
| 186 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - return trim( strtoupper( $current ) ); |
|
| 189 | + return trim(strtoupper($current)); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -194,25 +194,25 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @param string|null $currency The currency code. Defaults to the default currency. |
| 196 | 196 | */ |
| 197 | -function wpinv_currency_symbol( $currency = null ) { |
|
| 197 | +function wpinv_currency_symbol($currency = null) { |
|
| 198 | 198 | |
| 199 | 199 | // Prepare the currency. |
| 200 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
| 200 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
| 201 | 201 | |
| 202 | 202 | // Fetch all symbols. |
| 203 | 203 | $symbols = wpinv_get_currency_symbols(); |
| 204 | 204 | |
| 205 | 205 | // Fetch this currencies symbol. |
| 206 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
| 206 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
| 207 | 207 | |
| 208 | 208 | // Filter the symbol. |
| 209 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
| 209 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | function wpinv_currency_position() { |
| 213 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
| 213 | + $position = wpinv_get_option('currency_position', 'left'); |
|
| 214 | 214 | |
| 215 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
| 215 | + return apply_filters('wpinv_currency_position', $position); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @param $string|null $current |
| 222 | 222 | */ |
| 223 | -function wpinv_thousands_separator( $current = null ) { |
|
| 223 | +function wpinv_thousands_separator($current = null) { |
|
| 224 | 224 | |
| 225 | - if ( null == $current ) { |
|
| 226 | - $current = wpinv_get_option( 'thousands_separator', ',' ); |
|
| 225 | + if (null == $current) { |
|
| 226 | + $current = wpinv_get_option('thousands_separator', ','); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - return trim( $current ); |
|
| 229 | + return trim($current); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @param $string|null $current |
| 236 | 236 | */ |
| 237 | -function wpinv_decimal_separator( $current = null ) { |
|
| 237 | +function wpinv_decimal_separator($current = null) { |
|
| 238 | 238 | |
| 239 | - if ( null == $current ) { |
|
| 240 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
| 239 | + if (null == $current) { |
|
| 240 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - return trim( $current ); |
|
| 243 | + return trim($current); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -248,27 +248,27 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * @param $string|null $current |
| 250 | 250 | */ |
| 251 | -function wpinv_decimals( $current = null ) { |
|
| 251 | +function wpinv_decimals($current = null) { |
|
| 252 | 252 | |
| 253 | - if ( null == $current ) { |
|
| 254 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
| 253 | + if (null == $current) { |
|
| 254 | + $current = wpinv_get_option('decimals', 2); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - return absint( $current ); |
|
| 257 | + return absint($current); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | 261 | * Retrieves a list of all supported currencies. |
| 262 | 262 | */ |
| 263 | 263 | function wpinv_get_currencies() { |
| 264 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
| 264 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Retrieves a list of all currency symbols. |
| 269 | 269 | */ |
| 270 | 270 | function wpinv_get_currency_symbols() { |
| 271 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
| 271 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $currency_pos = wpinv_currency_position(); |
| 281 | 281 | $format = '%1$s%2$s'; |
| 282 | 282 | |
| 283 | - switch ( $currency_pos ) { |
|
| 283 | + switch ($currency_pos) { |
|
| 284 | 284 | case 'left': |
| 285 | 285 | $format = '%1$s%2$s'; |
| 286 | 286 | break; |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | break; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
| 298 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -305,25 +305,25 @@ discard block |
||
| 305 | 305 | * @param string $currency Currency. |
| 306 | 306 | * @return string |
| 307 | 307 | */ |
| 308 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
| 308 | +function wpinv_price($amount = 0, $currency = '') { |
|
| 309 | 309 | |
| 310 | 310 | // Backwards compatibility. |
| 311 | - $amount = wpinv_sanitize_amount( $amount ); |
|
| 311 | + $amount = wpinv_sanitize_amount($amount); |
|
| 312 | 312 | |
| 313 | 313 | // Prepare variables. |
| 314 | - $currency = wpinv_get_currency( $currency ); |
|
| 314 | + $currency = wpinv_get_currency($currency); |
|
| 315 | 315 | $amount = (float) $amount; |
| 316 | 316 | $unformatted_amount = $amount; |
| 317 | 317 | $negative = $amount < 0; |
| 318 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
| 319 | - $amount = wpinv_format_amount( $amount ); |
|
| 318 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
| 319 | + $amount = wpinv_format_amount($amount); |
|
| 320 | 320 | |
| 321 | 321 | // Format the amount. |
| 322 | 322 | $format = getpaid_get_price_format(); |
| 323 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
| 323 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
| 324 | 324 | |
| 325 | 325 | // Filter the formatting. |
| 326 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
| 326 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -334,25 +334,25 @@ discard block |
||
| 334 | 334 | * @param bool $calculate Whether or not to apply separators. |
| 335 | 335 | * @return string |
| 336 | 336 | */ |
| 337 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
| 337 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
| 338 | 338 | $thousands_sep = wpinv_thousands_separator(); |
| 339 | 339 | $decimal_sep = wpinv_decimal_separator(); |
| 340 | - $decimals = wpinv_decimals( $decimals ); |
|
| 341 | - $amount = wpinv_sanitize_amount( $amount ); |
|
| 340 | + $decimals = wpinv_decimals($decimals); |
|
| 341 | + $amount = wpinv_sanitize_amount($amount); |
|
| 342 | 342 | |
| 343 | - if ( $calculate ) { |
|
| 343 | + if ($calculate) { |
|
| 344 | 344 | return $amount; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // Fomart the amount. |
| 348 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 348 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | -function wpinv_sanitize_key( $key ) { |
|
| 351 | +function wpinv_sanitize_key($key) { |
|
| 352 | 352 | $raw_key = $key; |
| 353 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
| 353 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
| 354 | 354 | |
| 355 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
| 355 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -360,8 +360,8 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @param $str the file whose extension should be retrieved. |
| 362 | 362 | */ |
| 363 | -function wpinv_get_file_extension( $str ) { |
|
| 364 | - $filetype = wp_check_filetype( $str ); |
|
| 363 | +function wpinv_get_file_extension($str) { |
|
| 364 | + $filetype = wp_check_filetype($str); |
|
| 365 | 365 | return $filetype['ext']; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -370,16 +370,16 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | * @param string $string |
| 372 | 372 | */ |
| 373 | -function wpinv_string_is_image_url( $string ) { |
|
| 374 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
| 375 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
| 373 | +function wpinv_string_is_image_url($string) { |
|
| 374 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
| 375 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | 379 | * Returns the current URL. |
| 380 | 380 | */ |
| 381 | 381 | function wpinv_get_current_page_url() { |
| 382 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 382 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -389,46 +389,46 @@ discard block |
||
| 389 | 389 | * @param string $name Constant name. |
| 390 | 390 | * @param mixed $value Value. |
| 391 | 391 | */ |
| 392 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
| 393 | - if ( ! defined( $name ) ) { |
|
| 394 | - define( $name, $value ); |
|
| 392 | +function getpaid_maybe_define_constant($name, $value) { |
|
| 393 | + if (!defined($name)) { |
|
| 394 | + define($name, $value); |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function wpinv_get_php_arg_separator_output() { |
| 399 | - return ini_get( 'arg_separator.output' ); |
|
| 399 | + return ini_get('arg_separator.output'); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | -function wpinv_rgb_from_hex( $color ) { |
|
| 403 | - $color = str_replace( '#', '', $color ); |
|
| 402 | +function wpinv_rgb_from_hex($color) { |
|
| 403 | + $color = str_replace('#', '', $color); |
|
| 404 | 404 | |
| 405 | 405 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
| 406 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
| 407 | - if ( empty( $color ) ) { |
|
| 406 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
| 407 | + if (empty($color)) { |
|
| 408 | 408 | return NULL; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - $color = str_split( $color ); |
|
| 411 | + $color = str_split($color); |
|
| 412 | 412 | |
| 413 | 413 | $rgb = array(); |
| 414 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
| 415 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
| 416 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
| 414 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
| 415 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
| 416 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
| 417 | 417 | |
| 418 | 418 | return $rgb; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
| 422 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 421 | +function wpinv_hex_darker($color, $factor = 30) { |
|
| 422 | + $base = wpinv_rgb_from_hex($color); |
|
| 423 | 423 | $color = '#'; |
| 424 | 424 | |
| 425 | - foreach ( $base as $k => $v ) { |
|
| 425 | + foreach ($base as $k => $v) { |
|
| 426 | 426 | $amount = $v / 100; |
| 427 | - $amount = round( $amount * $factor ); |
|
| 427 | + $amount = round($amount * $factor); |
|
| 428 | 428 | $new_decimal = $v - $amount; |
| 429 | 429 | |
| 430 | - $new_hex_component = dechex( $new_decimal ); |
|
| 431 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 430 | + $new_hex_component = dechex($new_decimal); |
|
| 431 | + if (strlen($new_hex_component) < 2) { |
|
| 432 | 432 | $new_hex_component = "0" . $new_hex_component; |
| 433 | 433 | } |
| 434 | 434 | $color .= $new_hex_component; |
@@ -437,18 +437,18 @@ discard block |
||
| 437 | 437 | return $color; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
| 441 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 440 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
| 441 | + $base = wpinv_rgb_from_hex($color); |
|
| 442 | 442 | $color = '#'; |
| 443 | 443 | |
| 444 | - foreach ( $base as $k => $v ) { |
|
| 444 | + foreach ($base as $k => $v) { |
|
| 445 | 445 | $amount = 255 - $v; |
| 446 | 446 | $amount = $amount / 100; |
| 447 | - $amount = round( $amount * $factor ); |
|
| 447 | + $amount = round($amount * $factor); |
|
| 448 | 448 | $new_decimal = $v + $amount; |
| 449 | 449 | |
| 450 | - $new_hex_component = dechex( $new_decimal ); |
|
| 451 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 450 | + $new_hex_component = dechex($new_decimal); |
|
| 451 | + if (strlen($new_hex_component) < 2) { |
|
| 452 | 452 | $new_hex_component = "0" . $new_hex_component; |
| 453 | 453 | } |
| 454 | 454 | $color .= $new_hex_component; |
@@ -457,22 +457,22 @@ discard block |
||
| 457 | 457 | return $color; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
| 461 | - $hex = str_replace( '#', '', $color ); |
|
| 460 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
| 461 | + $hex = str_replace('#', '', $color); |
|
| 462 | 462 | |
| 463 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 464 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 465 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 463 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
| 464 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
| 465 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
| 466 | 466 | |
| 467 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
| 467 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
| 468 | 468 | |
| 469 | 469 | return $brightness > 155 ? $dark : $light; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | -function wpinv_format_hex( $hex ) { |
|
| 473 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
| 472 | +function wpinv_format_hex($hex) { |
|
| 473 | + $hex = trim(str_replace('#', '', $hex)); |
|
| 474 | 474 | |
| 475 | - if ( strlen( $hex ) == 3 ) { |
|
| 475 | + if (strlen($hex) == 3) { |
|
| 476 | 476 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
| 477 | 477 | } |
| 478 | 478 | |
@@ -492,12 +492,12 @@ discard block |
||
| 492 | 492 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 493 | 493 | * @return string |
| 494 | 494 | */ |
| 495 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 496 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 497 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 495 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 496 | + if (function_exists('mb_strimwidth')) { |
|
| 497 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 500 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
@@ -509,28 +509,28 @@ discard block |
||
| 509 | 509 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 510 | 510 | * @return int Returns the number of characters in string. |
| 511 | 511 | */ |
| 512 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 513 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 514 | - return mb_strlen( $str, $encoding ); |
|
| 512 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 513 | + if (function_exists('mb_strlen')) { |
|
| 514 | + return mb_strlen($str, $encoding); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - return strlen( $str ); |
|
| 517 | + return strlen($str); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
| 521 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
| 522 | - return mb_strtolower( $str, $encoding ); |
|
| 520 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
| 521 | + if (function_exists('mb_strtolower')) { |
|
| 522 | + return mb_strtolower($str, $encoding); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - return strtolower( $str ); |
|
| 525 | + return strtolower($str); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
| 529 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
| 530 | - return mb_strtoupper( $str, $encoding ); |
|
| 528 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
| 529 | + if (function_exists('mb_strtoupper')) { |
|
| 530 | + return mb_strtoupper($str, $encoding); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - return strtoupper( $str ); |
|
| 533 | + return strtoupper($str); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
@@ -544,12 +544,12 @@ discard block |
||
| 544 | 544 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 545 | 545 | * @return int Returns the position of the first occurrence of search in the string. |
| 546 | 546 | */ |
| 547 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 548 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 549 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 547 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 548 | + if (function_exists('mb_strpos')) { |
|
| 549 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - return strpos( $str, $find, $offset ); |
|
| 552 | + return strpos($str, $find, $offset); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | /** |
@@ -563,12 +563,12 @@ discard block |
||
| 563 | 563 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 564 | 564 | * @return int Returns the position of the last occurrence of search. |
| 565 | 565 | */ |
| 566 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 567 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 568 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 566 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 567 | + if (function_exists('mb_strrpos')) { |
|
| 568 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - return strrpos( $str, $find, $offset ); |
|
| 571 | + return strrpos($str, $find, $offset); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -583,16 +583,16 @@ discard block |
||
| 583 | 583 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 584 | 584 | * @return string |
| 585 | 585 | */ |
| 586 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 587 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 588 | - if ( $length === null ) { |
|
| 589 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 586 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 587 | + if (function_exists('mb_substr')) { |
|
| 588 | + if ($length === null) { |
|
| 589 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 590 | 590 | } else { |
| 591 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 591 | + return mb_substr($str, $start, $length, $encoding); |
|
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - return substr( $str, $start, $length ); |
|
| 595 | + return substr($str, $start, $length); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | /** |
@@ -604,48 +604,48 @@ discard block |
||
| 604 | 604 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 605 | 605 | * @return string The width of string. |
| 606 | 606 | */ |
| 607 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 608 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 609 | - return mb_strwidth( $str, $encoding ); |
|
| 607 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 608 | + if (function_exists('mb_strwidth')) { |
|
| 609 | + return mb_strwidth($str, $encoding); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
| 612 | + return wpinv_utf8_strlen($str, $encoding); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 616 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 617 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 615 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 616 | + if (function_exists('mb_strlen')) { |
|
| 617 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 618 | 618 | $str_end = ""; |
| 619 | 619 | |
| 620 | - if ( $lower_str_end ) { |
|
| 621 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 620 | + if ($lower_str_end) { |
|
| 621 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 622 | 622 | } else { |
| 623 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 623 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | return $first_letter . $str_end; |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - return ucfirst( $str ); |
|
| 629 | + return ucfirst($str); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
| 633 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
| 634 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
| 632 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
| 633 | + if (function_exists('mb_convert_case')) { |
|
| 634 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - return ucwords( $str ); |
|
| 637 | + return ucwords($str); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | -function wpinv_period_in_days( $period, $unit ) { |
|
| 641 | - $period = absint( $period ); |
|
| 640 | +function wpinv_period_in_days($period, $unit) { |
|
| 641 | + $period = absint($period); |
|
| 642 | 642 | |
| 643 | - if ( $period > 0 ) { |
|
| 644 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
| 643 | + if ($period > 0) { |
|
| 644 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
| 645 | 645 | $period = $period * 7; |
| 646 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
| 646 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
| 647 | 647 | $period = $period * 30; |
| 648 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
| 648 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
| 649 | 649 | $period = $period * 365; |
| 650 | 650 | } |
| 651 | 651 | } |
@@ -653,14 +653,14 @@ discard block |
||
| 653 | 653 | return $period; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
| 657 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
| 658 | - return cal_days_in_month( $calendar, $month, $year ); |
|
| 656 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
| 657 | + if (function_exists('cal_days_in_month')) { |
|
| 658 | + return cal_days_in_month($calendar, $month, $year); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | // Fallback in case the calendar extension is not loaded in PHP |
| 662 | 662 | // Only supports Gregorian calendar |
| 663 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 663 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | /** |
@@ -671,12 +671,12 @@ discard block |
||
| 671 | 671 | * |
| 672 | 672 | * @return string |
| 673 | 673 | */ |
| 674 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
| 674 | +function wpi_help_tip($tip, $allow_html = false) { |
|
| 675 | 675 | |
| 676 | - if ( $allow_html ) { |
|
| 677 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
| 676 | + if ($allow_html) { |
|
| 677 | + $tip = wpi_sanitize_tooltip($tip); |
|
| 678 | 678 | } else { |
| 679 | - $tip = esc_attr( $tip ); |
|
| 679 | + $tip = esc_attr($tip); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -690,8 +690,8 @@ discard block |
||
| 690 | 690 | * @param string $var |
| 691 | 691 | * @return string |
| 692 | 692 | */ |
| 693 | -function wpi_sanitize_tooltip( $var ) { |
|
| 694 | - return wp_kses( html_entity_decode( $var ), array( |
|
| 693 | +function wpi_sanitize_tooltip($var) { |
|
| 694 | + return wp_kses(html_entity_decode($var), array( |
|
| 695 | 695 | 'br' => array(), |
| 696 | 696 | 'em' => array(), |
| 697 | 697 | 'strong' => array(), |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | 'li' => array(), |
| 703 | 703 | 'ol' => array(), |
| 704 | 704 | 'p' => array(), |
| 705 | - ) ); |
|
| 705 | + )); |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | */ |
| 713 | 713 | function wpinv_get_screen_ids() { |
| 714 | 714 | |
| 715 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
| 715 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
| 716 | 716 | |
| 717 | 717 | $screen_ids = array( |
| 718 | 718 | 'toplevel_page_' . $screen_id, |
@@ -731,10 +731,10 @@ discard block |
||
| 731 | 731 | 'getpaid_page_wpinv-reports', |
| 732 | 732 | 'getpaid_page_wpi-addons', |
| 733 | 733 | 'getpaid_page_wpinv-customers', |
| 734 | - 'gp-setup',// setup wizard |
|
| 734 | + 'gp-setup', // setup wizard |
|
| 735 | 735 | ); |
| 736 | 736 | |
| 737 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
| 737 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
@@ -745,14 +745,14 @@ discard block |
||
| 745 | 745 | * @param array|string $list List of values. |
| 746 | 746 | * @return array Sanitized array of values. |
| 747 | 747 | */ |
| 748 | -function wpinv_parse_list( $list ) { |
|
| 748 | +function wpinv_parse_list($list) { |
|
| 749 | 749 | |
| 750 | - if ( empty( $list ) ) { |
|
| 750 | + if (empty($list)) { |
|
| 751 | 751 | $list = array(); |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if ( ! is_array( $list ) ) { |
|
| 755 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
| 754 | + if (!is_array($list)) { |
|
| 755 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | return $list; |
@@ -766,16 +766,16 @@ discard block |
||
| 766 | 766 | * @param string $key Type of data to fetch. |
| 767 | 767 | * @return mixed Fetched data. |
| 768 | 768 | */ |
| 769 | -function wpinv_get_data( $key ) { |
|
| 769 | +function wpinv_get_data($key) { |
|
| 770 | 770 | |
| 771 | 771 | // Try fetching it from the cache. |
| 772 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
| 773 | - if( $data ) { |
|
| 772 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
| 773 | + if ($data) { |
|
| 774 | 774 | return $data; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
| 778 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
| 777 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
| 778 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
| 779 | 779 | |
| 780 | 780 | return $data; |
| 781 | 781 | } |
@@ -789,10 +789,10 @@ discard block |
||
| 789 | 789 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 790 | 790 | * @return mixed Fetched data. |
| 791 | 791 | */ |
| 792 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
| 792 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
| 793 | 793 | |
| 794 | - if ( ! empty( $options ) && $first_empty ) { |
|
| 795 | - return array_merge( array( '' => '' ), $options ); |
|
| 794 | + if (!empty($options) && $first_empty) { |
|
| 795 | + return array_merge(array('' => ''), $options); |
|
| 796 | 796 | } |
| 797 | 797 | return $options; |
| 798 | 798 | |
@@ -804,21 +804,21 @@ discard block |
||
| 804 | 804 | * @param mixed $var Data to sanitize. |
| 805 | 805 | * @return string|array |
| 806 | 806 | */ |
| 807 | -function wpinv_clean( $var ) { |
|
| 807 | +function wpinv_clean($var) { |
|
| 808 | 808 | |
| 809 | - if ( is_array( $var ) ) { |
|
| 810 | - return array_map( 'wpinv_clean', $var ); |
|
| 809 | + if (is_array($var)) { |
|
| 810 | + return array_map('wpinv_clean', $var); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | - if ( is_object( $var ) ) { |
|
| 814 | - $object_vars = get_object_vars( $var ); |
|
| 815 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 816 | - $var->$property_name = wpinv_clean( $property_value ); |
|
| 813 | + if (is_object($var)) { |
|
| 814 | + $object_vars = get_object_vars($var); |
|
| 815 | + foreach ($object_vars as $property_name => $property_value) { |
|
| 816 | + $var->$property_name = wpinv_clean($property_value); |
|
| 817 | 817 | } |
| 818 | 818 | return $var; |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
|
| 821 | + return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var; |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -827,43 +827,43 @@ discard block |
||
| 827 | 827 | * @param string $str Data to convert. |
| 828 | 828 | * @return string|array |
| 829 | 829 | */ |
| 830 | -function getpaid_convert_price_string_to_options( $str ) { |
|
| 830 | +function getpaid_convert_price_string_to_options($str) { |
|
| 831 | 831 | |
| 832 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
| 833 | - $options = array(); |
|
| 832 | + $raw_options = array_map('trim', explode(',', $str)); |
|
| 833 | + $options = array(); |
|
| 834 | 834 | |
| 835 | - foreach ( $raw_options as $option ) { |
|
| 835 | + foreach ($raw_options as $option) { |
|
| 836 | 836 | |
| 837 | - if ( '' == $option ) { |
|
| 837 | + if ('' == $option) { |
|
| 838 | 838 | continue; |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
| 841 | + $option = array_map('trim', explode('|', $option)); |
|
| 842 | 842 | |
| 843 | 843 | $price = null; |
| 844 | 844 | $label = null; |
| 845 | 845 | |
| 846 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
| 847 | - $label = $option[0]; |
|
| 846 | + if (isset($option[0]) && '' != $option[0]) { |
|
| 847 | + $label = $option[0]; |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
| 850 | + if (isset($option[1]) && '' != $option[1]) { |
|
| 851 | 851 | $price = $option[1]; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - if ( ! isset( $price ) ) { |
|
| 854 | + if (!isset($price)) { |
|
| 855 | 855 | $price = $label; |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
| 858 | + if (!isset($price) || !is_numeric($price)) { |
|
| 859 | 859 | continue; |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - if ( ! isset( $label ) ) { |
|
| 862 | + if (!isset($label)) { |
|
| 863 | 863 | $label = $price; |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | - $options[ "$label|$price" ] = $label; |
|
| 866 | + $options["$label|$price"] = $label; |
|
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | return $options; |
@@ -872,27 +872,27 @@ discard block |
||
| 872 | 872 | /** |
| 873 | 873 | * Returns the help tip. |
| 874 | 874 | */ |
| 875 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
| 876 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
| 877 | - $tip = esc_attr__( $tip ); |
|
| 875 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
| 876 | + $additional_classes = sanitize_html_class($additional_classes); |
|
| 877 | + $tip = esc_attr__($tip); |
|
| 878 | 878 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
| 882 | 882 | * Formats a date |
| 883 | 883 | */ |
| 884 | -function getpaid_format_date( $date, $with_time = false ) { |
|
| 884 | +function getpaid_format_date($date, $with_time = false) { |
|
| 885 | 885 | |
| 886 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
| 886 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
| 887 | 887 | return ''; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | $format = getpaid_date_format(); |
| 891 | 891 | |
| 892 | - if ( $with_time ) { |
|
| 892 | + if ($with_time) { |
|
| 893 | 893 | $format .= ' ' . getpaid_time_format(); |
| 894 | 894 | } |
| 895 | - return date_i18n( $format, strtotime( $date ) ); |
|
| 895 | + return date_i18n($format, strtotime($date)); |
|
| 896 | 896 | |
| 897 | 897 | } |
| 898 | 898 | |
@@ -901,9 +901,9 @@ discard block |
||
| 901 | 901 | * |
| 902 | 902 | * @return string |
| 903 | 903 | */ |
| 904 | -function getpaid_format_date_value( $date, $default = "—", $with_time = false ) { |
|
| 905 | - $date = getpaid_format_date( $date, $with_time ); |
|
| 906 | - return empty( $date ) ? $default : $date; |
|
| 904 | +function getpaid_format_date_value($date, $default = "—", $with_time = false) { |
|
| 905 | + $date = getpaid_format_date($date, $with_time); |
|
| 906 | + return empty($date) ? $default : $date; |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | /** |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | * @return string |
| 913 | 913 | */ |
| 914 | 914 | function getpaid_date_format() { |
| 915 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
| 915 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | /** |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @return string |
| 922 | 922 | */ |
| 923 | 923 | function getpaid_time_format() { |
| 924 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
| 924 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
@@ -931,16 +931,16 @@ discard block |
||
| 931 | 931 | * @param integer $limit Limit size in characters. |
| 932 | 932 | * @return string |
| 933 | 933 | */ |
| 934 | -function getpaid_limit_length( $string, $limit ) { |
|
| 934 | +function getpaid_limit_length($string, $limit) { |
|
| 935 | 935 | $str_limit = $limit - 3; |
| 936 | 936 | |
| 937 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 938 | - if ( mb_strlen( $string ) > $limit ) { |
|
| 939 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
| 937 | + if (function_exists('mb_strimwidth')) { |
|
| 938 | + if (mb_strlen($string) > $limit) { |
|
| 939 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
| 940 | 940 | } |
| 941 | 941 | } else { |
| 942 | - if ( strlen( $string ) > $limit ) { |
|
| 943 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
| 942 | + if (strlen($string) > $limit) { |
|
| 943 | + $string = substr($string, 0, $str_limit) . '...'; |
|
| 944 | 944 | } |
| 945 | 945 | } |
| 946 | 946 | return $string; |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | * @since 1.0.19 |
| 955 | 955 | */ |
| 956 | 956 | function getpaid_api() { |
| 957 | - return getpaid()->get( 'api' ); |
|
| 957 | + return getpaid()->get('api'); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * @since 1.0.19 |
| 965 | 965 | */ |
| 966 | 966 | function getpaid_post_types() { |
| 967 | - return getpaid()->get( 'post_types' ); |
|
| 967 | + return getpaid()->get('post_types'); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | * @since 1.0.19 |
| 975 | 975 | */ |
| 976 | 976 | function getpaid_session() { |
| 977 | - return getpaid()->get( 'session' ); |
|
| 977 | + return getpaid()->get('session'); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | * @since 1.0.19 |
| 985 | 985 | */ |
| 986 | 986 | function getpaid_notes() { |
| 987 | - return getpaid()->get( 'notes' ); |
|
| 987 | + return getpaid()->get('notes'); |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | /** |
@@ -993,7 +993,7 @@ discard block |
||
| 993 | 993 | * @return GetPaid_Admin |
| 994 | 994 | */ |
| 995 | 995 | function getpaid_admin() { |
| 996 | - return getpaid()->get( 'admin' ); |
|
| 996 | + return getpaid()->get('admin'); |
|
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | /** |
@@ -1003,8 +1003,8 @@ discard block |
||
| 1003 | 1003 | * @param string $base the base url |
| 1004 | 1004 | * @return string |
| 1005 | 1005 | */ |
| 1006 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
| 1007 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 1006 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
| 1007 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | /** |
@@ -1012,11 +1012,11 @@ discard block |
||
| 1012 | 1012 | * |
| 1013 | 1013 | * @return string |
| 1014 | 1014 | */ |
| 1015 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
| 1015 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
| 1016 | 1016 | |
| 1017 | - $post_type = get_post_type_object( $post_type ); |
|
| 1017 | + $post_type = get_post_type_object($post_type); |
|
| 1018 | 1018 | |
| 1019 | - if ( ! is_object( $post_type ) ) { |
|
| 1019 | + if (!is_object($post_type)) { |
|
| 1020 | 1020 | return null; |
| 1021 | 1021 | } |
| 1022 | 1022 | |
@@ -1029,18 +1029,18 @@ discard block |
||
| 1029 | 1029 | * |
| 1030 | 1030 | * @return mixed|null |
| 1031 | 1031 | */ |
| 1032 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
| 1032 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
| 1033 | 1033 | |
| 1034 | - if ( ! is_array( $array ) ) { |
|
| 1034 | + if (!is_array($array)) { |
|
| 1035 | 1035 | return null; |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | - if ( ! empty( $secondary_key ) ) { |
|
| 1039 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
| 1040 | - return getpaid_get_array_field( $array, $key ); |
|
| 1038 | + if (!empty($secondary_key)) { |
|
| 1039 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
| 1040 | + return getpaid_get_array_field($array, $key); |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
| 1043 | + return isset($array[$key]) ? $array[$key] : null; |
|
| 1044 | 1044 | |
| 1045 | 1045 | } |
| 1046 | 1046 | |
@@ -1049,12 +1049,12 @@ discard block |
||
| 1049 | 1049 | * |
| 1050 | 1050 | * @return array |
| 1051 | 1051 | */ |
| 1052 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
| 1052 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
| 1053 | 1053 | |
| 1054 | - foreach ( $defaults as $key => $value ) { |
|
| 1054 | + foreach ($defaults as $key => $value) { |
|
| 1055 | 1055 | |
| 1056 | - if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) { |
|
| 1057 | - $args[ $key ] = $value; |
|
| 1056 | + if (array_key_exists($key, $args) && empty($args[$key])) { |
|
| 1057 | + $args[$key] = $value; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | } |
@@ -1072,12 +1072,12 @@ discard block |
||
| 1072 | 1072 | |
| 1073 | 1073 | $types = get_allowed_mime_types(); |
| 1074 | 1074 | |
| 1075 | - if ( isset( $types['htm|html'] ) ) { |
|
| 1076 | - unset( $types['htm|html'] ); |
|
| 1075 | + if (isset($types['htm|html'])) { |
|
| 1076 | + unset($types['htm|html']); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - if ( isset( $types['js'] ) ) { |
|
| 1080 | - unset( $types['js'] ); |
|
| 1079 | + if (isset($types['js'])) { |
|
| 1080 | + unset($types['js']); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | return $types; |
@@ -9,41 +9,41 @@ discard block |
||
| 9 | 9 | * @version 1.0.19 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | 16 | array( |
| 17 | 17 | 'type' => 'heading', |
| 18 | - 'name' => __( 'Heading', 'invoicing' ), |
|
| 18 | + 'name' => __('Heading', 'invoicing'), |
|
| 19 | 19 | 'defaults' => array( |
| 20 | 20 | 'level' => 'h2', |
| 21 | - 'text' => __( 'Heading', 'invoicing' ), |
|
| 21 | + 'text' => __('Heading', 'invoicing'), |
|
| 22 | 22 | ) |
| 23 | 23 | ), |
| 24 | 24 | |
| 25 | 25 | array( |
| 26 | 26 | 'type' => 'paragraph', |
| 27 | - 'name' => __( 'Paragraph', 'invoicing' ), |
|
| 27 | + 'name' => __('Paragraph', 'invoicing'), |
|
| 28 | 28 | 'defaults' => array( |
| 29 | - 'text' => __( 'Paragraph text', 'invoicing' ), |
|
| 29 | + 'text' => __('Paragraph text', 'invoicing'), |
|
| 30 | 30 | ) |
| 31 | 31 | ), |
| 32 | 32 | |
| 33 | 33 | array( |
| 34 | 34 | 'type' => 'alert', |
| 35 | - 'name' => __( 'Alert', 'invoicing' ), |
|
| 35 | + 'name' => __('Alert', 'invoicing'), |
|
| 36 | 36 | 'defaults' => array( |
| 37 | 37 | 'value' => '', |
| 38 | 38 | 'class' => 'alert-warning', |
| 39 | - 'text' => __( 'Alert', 'invoicing' ), |
|
| 39 | + 'text' => __('Alert', 'invoicing'), |
|
| 40 | 40 | 'dismissible' => false, |
| 41 | 41 | ) |
| 42 | 42 | ), |
| 43 | 43 | |
| 44 | 44 | array( |
| 45 | 45 | 'type' => 'separator', |
| 46 | - 'name' => __( 'Separator', 'invoicing' ), |
|
| 46 | + 'name' => __('Separator', 'invoicing'), |
|
| 47 | 47 | 'defaults' => array( |
| 48 | 48 | 'value' => '', |
| 49 | 49 | ), |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | array( |
| 53 | 53 | 'type' => 'text', |
| 54 | - 'name' => __( 'Text Input', 'invoicing' ), |
|
| 54 | + 'name' => __('Text Input', 'invoicing'), |
|
| 55 | 55 | 'defaults' => array( |
| 56 | - 'placeholder' => __( 'Enter some text', 'invoicing' ), |
|
| 56 | + 'placeholder' => __('Enter some text', 'invoicing'), |
|
| 57 | 57 | 'value' => '', |
| 58 | - 'label' => __( 'Field Label', 'invoicing' ), |
|
| 58 | + 'label' => __('Field Label', 'invoicing'), |
|
| 59 | 59 | 'description' => '', |
| 60 | 60 | 'required' => false, |
| 61 | 61 | ) |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | array( |
| 65 | 65 | 'type' => 'textarea', |
| 66 | - 'name' => __( 'Textarea', 'invoicing' ), |
|
| 66 | + 'name' => __('Textarea', 'invoicing'), |
|
| 67 | 67 | 'defaults' => array( |
| 68 | - 'placeholder' => __( 'Enter your text here', 'invoicing' ), |
|
| 68 | + 'placeholder' => __('Enter your text here', 'invoicing'), |
|
| 69 | 69 | 'value' => '', |
| 70 | - 'label' => __( 'Textarea Label', 'invoicing' ), |
|
| 70 | + 'label' => __('Textarea Label', 'invoicing'), |
|
| 71 | 71 | 'description' => '', |
| 72 | 72 | 'required' => false, |
| 73 | 73 | ) |
@@ -75,27 +75,27 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | array( |
| 77 | 77 | 'type' => 'select', |
| 78 | - 'name' => __( 'Dropdown', 'invoicing' ), |
|
| 78 | + 'name' => __('Dropdown', 'invoicing'), |
|
| 79 | 79 | 'defaults' => array( |
| 80 | - 'placeholder' => __( 'Select a value', 'invoicing' ), |
|
| 80 | + 'placeholder' => __('Select a value', 'invoicing'), |
|
| 81 | 81 | 'value' => '', |
| 82 | - 'label' => __( 'Dropdown Label', 'invoicing' ), |
|
| 82 | + 'label' => __('Dropdown Label', 'invoicing'), |
|
| 83 | 83 | 'description' => '', |
| 84 | 84 | 'required' => false, |
| 85 | 85 | 'options' => array( |
| 86 | - esc_attr__( 'Option One', 'invoicing' ), |
|
| 87 | - esc_attr__( 'Option Two', 'invoicing' ), |
|
| 88 | - esc_attr__( 'Option Three', 'invoicing' ) |
|
| 86 | + esc_attr__('Option One', 'invoicing'), |
|
| 87 | + esc_attr__('Option Two', 'invoicing'), |
|
| 88 | + esc_attr__('Option Three', 'invoicing') |
|
| 89 | 89 | ), |
| 90 | 90 | ) |
| 91 | 91 | ), |
| 92 | 92 | |
| 93 | 93 | array( |
| 94 | 94 | 'type' => 'checkbox', |
| 95 | - 'name' => __( 'Checkbox', 'invoicing' ), |
|
| 95 | + 'name' => __('Checkbox', 'invoicing'), |
|
| 96 | 96 | 'defaults' => array( |
| 97 | 97 | 'value' => '', |
| 98 | - 'label' => __( 'Checkbox Label', 'invoicing' ), |
|
| 98 | + 'label' => __('Checkbox Label', 'invoicing'), |
|
| 99 | 99 | 'description' => '', |
| 100 | 100 | 'required' => false, |
| 101 | 101 | ) |
@@ -103,23 +103,23 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | array( |
| 105 | 105 | 'type' => 'radio', |
| 106 | - 'name' => __( 'Radio', 'invoicing' ), |
|
| 106 | + 'name' => __('Radio', 'invoicing'), |
|
| 107 | 107 | 'defaults' => array( |
| 108 | - 'label' => __( 'Select one choice', 'invoicing' ), |
|
| 108 | + 'label' => __('Select one choice', 'invoicing'), |
|
| 109 | 109 | 'options' => array( |
| 110 | - esc_attr__( 'Choice One', 'invoicing' ), |
|
| 111 | - esc_attr__( 'Choice Two', 'invoicing' ), |
|
| 112 | - esc_attr__( 'Choice Three', 'invoicing' ) |
|
| 110 | + esc_attr__('Choice One', 'invoicing'), |
|
| 111 | + esc_attr__('Choice Two', 'invoicing'), |
|
| 112 | + esc_attr__('Choice Three', 'invoicing') |
|
| 113 | 113 | ), |
| 114 | 114 | ) |
| 115 | 115 | ), |
| 116 | 116 | |
| 117 | 117 | array( |
| 118 | 118 | 'type' => 'date', |
| 119 | - 'name' => __( 'Date', 'invoicing' ), |
|
| 119 | + 'name' => __('Date', 'invoicing'), |
|
| 120 | 120 | 'defaults' => array( |
| 121 | 121 | 'value' => '', |
| 122 | - 'label' => __( 'Date', 'invoicing' ), |
|
| 122 | + 'label' => __('Date', 'invoicing'), |
|
| 123 | 123 | 'description' => '', |
| 124 | 124 | 'required' => false, |
| 125 | 125 | ) |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | array( |
| 129 | 129 | 'type' => 'time', |
| 130 | - 'name' => __( 'Time', 'invoicing' ), |
|
| 130 | + 'name' => __('Time', 'invoicing'), |
|
| 131 | 131 | 'defaults' => array( |
| 132 | 132 | 'value' => '', |
| 133 | - 'label' => __( 'Time', 'invoicing' ), |
|
| 133 | + 'label' => __('Time', 'invoicing'), |
|
| 134 | 134 | 'description' => '', |
| 135 | 135 | 'required' => false, |
| 136 | 136 | ) |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | array( |
| 140 | 140 | 'type' => 'number', |
| 141 | - 'name' => __( 'Number', 'invoicing' ), |
|
| 141 | + 'name' => __('Number', 'invoicing'), |
|
| 142 | 142 | 'defaults' => array( |
| 143 | 143 | 'placeholder' => '', |
| 144 | 144 | 'value' => '', |
| 145 | - 'label' => __( 'Number', 'invoicing' ), |
|
| 145 | + 'label' => __('Number', 'invoicing'), |
|
| 146 | 146 | 'description' => '', |
| 147 | 147 | 'required' => false, |
| 148 | 148 | ) |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | array( |
| 152 | 152 | 'type' => 'website', |
| 153 | - 'name' => __( 'Website', 'invoicing' ), |
|
| 153 | + 'name' => __('Website', 'invoicing'), |
|
| 154 | 154 | 'defaults' => array( |
| 155 | 155 | 'placeholder' => 'http://example.com', |
| 156 | 156 | 'value' => '', |
| 157 | - 'label' => __( 'Website', 'invoicing' ), |
|
| 157 | + 'label' => __('Website', 'invoicing'), |
|
| 158 | 158 | 'description' => '', |
| 159 | 159 | 'required' => false, |
| 160 | 160 | ) |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | array( |
| 164 | 164 | 'type' => 'email', |
| 165 | - 'name' => __( 'Email', 'invoicing' ), |
|
| 165 | + 'name' => __('Email', 'invoicing'), |
|
| 166 | 166 | 'defaults' => array( |
| 167 | 167 | 'placeholder' => '[email protected]', |
| 168 | 168 | 'value' => '', |
| 169 | - 'label' => __( 'Email Address', 'invoicing' ), |
|
| 169 | + 'label' => __('Email Address', 'invoicing'), |
|
| 170 | 170 | 'description' => '', |
| 171 | 171 | 'required' => false, |
| 172 | 172 | ) |
@@ -174,31 +174,31 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | array( |
| 176 | 176 | 'type' => 'file_upload', |
| 177 | - 'name' => __( 'File Upload', 'invoicing' ), |
|
| 177 | + 'name' => __('File Upload', 'invoicing'), |
|
| 178 | 178 | 'defaults' => array( |
| 179 | 179 | 'value' => '', |
| 180 | - 'label' => __( 'Upload File', 'invoicing' ), |
|
| 180 | + 'label' => __('Upload File', 'invoicing'), |
|
| 181 | 181 | 'description' => '', |
| 182 | 182 | 'required' => false, |
| 183 | 183 | 'max_file_num' => 1, |
| 184 | - 'file_types' => array( 'jpg|jpeg|jpe', 'gif', 'png' ), |
|
| 184 | + 'file_types' => array('jpg|jpeg|jpe', 'gif', 'png'), |
|
| 185 | 185 | ) |
| 186 | 186 | ), |
| 187 | 187 | |
| 188 | 188 | array( |
| 189 | 189 | 'type' => 'address', |
| 190 | - 'name' => __( 'Address', 'invoicing' ), |
|
| 190 | + 'name' => __('Address', 'invoicing'), |
|
| 191 | 191 | 'defaults' => array( |
| 192 | 192 | |
| 193 | 193 | 'address_type' => 'billing', |
| 194 | - 'billing_address_title' => __( 'Billing Address', 'invoicing' ), |
|
| 195 | - 'shipping_address_title' => __( 'Shipping Address', 'invoicing' ), |
|
| 196 | - 'shipping_address_toggle' => __( 'Same billing & shipping address.', 'invoicing' ), |
|
| 194 | + 'billing_address_title' => __('Billing Address', 'invoicing'), |
|
| 195 | + 'shipping_address_title' => __('Shipping Address', 'invoicing'), |
|
| 196 | + 'shipping_address_toggle' => __('Same billing & shipping address.', 'invoicing'), |
|
| 197 | 197 | 'fields' => array( |
| 198 | 198 | array( |
| 199 | 199 | 'placeholder' => 'Jon', |
| 200 | 200 | 'value' => '', |
| 201 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 201 | + 'label' => __('First Name', 'invoicing'), |
|
| 202 | 202 | 'description' => '', |
| 203 | 203 | 'required' => false, |
| 204 | 204 | 'visible' => true, |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | array( |
| 210 | 210 | 'placeholder' => 'Snow', |
| 211 | 211 | 'value' => '', |
| 212 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 212 | + 'label' => __('Last Name', 'invoicing'), |
|
| 213 | 213 | 'description' => '', |
| 214 | 214 | 'required' => false, |
| 215 | 215 | 'visible' => true, |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | array( |
| 221 | 221 | 'placeholder' => '', |
| 222 | 222 | 'value' => '', |
| 223 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 223 | + 'label' => __('Address', 'invoicing'), |
|
| 224 | 224 | 'description' => '', |
| 225 | 225 | 'required' => false, |
| 226 | 226 | 'visible' => true, |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | array( |
| 232 | 232 | 'placeholder' => '', |
| 233 | 233 | 'value' => '', |
| 234 | - 'label' => __( 'City', 'invoicing' ), |
|
| 234 | + 'label' => __('City', 'invoicing'), |
|
| 235 | 235 | 'description' => '', |
| 236 | 236 | 'required' => false, |
| 237 | 237 | 'visible' => true, |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | ), |
| 241 | 241 | |
| 242 | 242 | array( |
| 243 | - 'placeholder' => __( 'Select your country' ), |
|
| 243 | + 'placeholder' => __('Select your country'), |
|
| 244 | 244 | 'value' => '', |
| 245 | - 'label' => __( 'Country', 'invoicing' ), |
|
| 245 | + 'label' => __('Country', 'invoicing'), |
|
| 246 | 246 | 'description' => '', |
| 247 | 247 | 'required' => false, |
| 248 | 248 | 'visible' => true, |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | ), |
| 252 | 252 | |
| 253 | 253 | array( |
| 254 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 254 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 255 | 255 | 'value' => '', |
| 256 | - 'label' => __( 'State / Province', 'invoicing' ), |
|
| 256 | + 'label' => __('State / Province', 'invoicing'), |
|
| 257 | 257 | 'description' => '', |
| 258 | 258 | 'required' => false, |
| 259 | 259 | 'visible' => true, |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | array( |
| 265 | 265 | 'placeholder' => '', |
| 266 | 266 | 'value' => '', |
| 267 | - 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 267 | + 'label' => __('ZIP / Postcode', 'invoicing'), |
|
| 268 | 268 | 'description' => '', |
| 269 | 269 | 'required' => false, |
| 270 | 270 | 'visible' => true, |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | array( |
| 276 | 276 | 'placeholder' => '', |
| 277 | 277 | 'value' => '', |
| 278 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 278 | + 'label' => __('Phone', 'invoicing'), |
|
| 279 | 279 | 'description' => '', |
| 280 | 280 | 'required' => false, |
| 281 | 281 | 'visible' => true, |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | array( |
| 287 | 287 | 'placeholder' => '', |
| 288 | 288 | 'value' => '', |
| 289 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 289 | + 'label' => __('Company', 'invoicing'), |
|
| 290 | 290 | 'description' => '', |
| 291 | 291 | 'required' => false, |
| 292 | 292 | 'visible' => false, |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | array( |
| 298 | 298 | 'placeholder' => '', |
| 299 | 299 | 'value' => '', |
| 300 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 300 | + 'label' => __('Company ID', 'invoicing'), |
|
| 301 | 301 | 'description' => '', |
| 302 | 302 | 'required' => false, |
| 303 | 303 | 'visible' => false, |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | array( |
| 309 | 309 | 'placeholder' => '', |
| 310 | 310 | 'value' => '', |
| 311 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 311 | + 'label' => __('VAT Number', 'invoicing'), |
|
| 312 | 312 | 'description' => '', |
| 313 | 313 | 'required' => false, |
| 314 | 314 | 'visible' => false, |
@@ -321,11 +321,11 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | array( |
| 323 | 323 | 'type' => 'billing_email', |
| 324 | - 'name' => __( 'Billing Email', 'invoicing' ), |
|
| 324 | + 'name' => __('Billing Email', 'invoicing'), |
|
| 325 | 325 | 'defaults' => array( |
| 326 | 326 | 'placeholder' => '[email protected]', |
| 327 | 327 | 'value' => '', |
| 328 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
| 328 | + 'label' => __('Billing Email', 'invoicing'), |
|
| 329 | 329 | 'description' => '', |
| 330 | 330 | 'premade' => true, |
| 331 | 331 | ) |
@@ -333,18 +333,18 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | array( |
| 335 | 335 | 'type' => 'discount', |
| 336 | - 'name' => __( 'Discount Input', 'invoicing' ), |
|
| 336 | + 'name' => __('Discount Input', 'invoicing'), |
|
| 337 | 337 | 'defaults' => array( |
| 338 | 338 | 'value' => '', |
| 339 | - 'input_label' => __( 'Coupon Code', 'invoicing' ), |
|
| 340 | - 'button_label' => __( 'Apply Coupon', 'invoicing' ), |
|
| 341 | - 'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
|
| 339 | + 'input_label' => __('Coupon Code', 'invoicing'), |
|
| 340 | + 'button_label' => __('Apply Coupon', 'invoicing'), |
|
| 341 | + 'description' => __('Have a discount code? Enter it above.', 'invoicing'), |
|
| 342 | 342 | ) |
| 343 | 343 | ), |
| 344 | 344 | |
| 345 | 345 | array( |
| 346 | 346 | 'type' => 'items', |
| 347 | - 'name' => __( 'Items', 'invoicing' ), |
|
| 347 | + 'name' => __('Items', 'invoicing'), |
|
| 348 | 348 | 'defaults' => array( |
| 349 | 349 | 'value' => '', |
| 350 | 350 | 'items_type' => 'total', |
@@ -356,22 +356,22 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | array( |
| 358 | 358 | 'type' => 'price_input', |
| 359 | - 'name' => __( 'Price Input', 'invoicing' ), |
|
| 359 | + 'name' => __('Price Input', 'invoicing'), |
|
| 360 | 360 | 'defaults' => array( |
| 361 | 361 | 'placeholder' => wpinv_format_amount(0), |
| 362 | 362 | 'value' => wpinv_format_amount(0), |
| 363 | 363 | 'minimum' => wpinv_format_amount(0), |
| 364 | - 'label' => __( 'Enter Amount', 'invoicing' ), |
|
| 364 | + 'label' => __('Enter Amount', 'invoicing'), |
|
| 365 | 365 | 'description' => '', |
| 366 | 366 | ) |
| 367 | 367 | ), |
| 368 | 368 | |
| 369 | 369 | array( |
| 370 | 370 | 'type' => 'price_select', |
| 371 | - 'name' => __( 'Price Select', 'invoicing' ), |
|
| 371 | + 'name' => __('Price Select', 'invoicing'), |
|
| 372 | 372 | 'defaults' => array( |
| 373 | 373 | 'description' => '', |
| 374 | - 'label' => __( 'Select Amount', 'invoicing' ), |
|
| 374 | + 'label' => __('Select Amount', 'invoicing'), |
|
| 375 | 375 | 'options' => 'Option 1|10, Option 2|20', |
| 376 | 376 | 'placeholder' => '', |
| 377 | 377 | 'select_type' => 'select', |
@@ -380,39 +380,39 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | array( |
| 382 | 382 | 'type' => 'pay_button', |
| 383 | - 'name' => __( 'Payment Button', 'invoicing' ), |
|
| 383 | + 'name' => __('Payment Button', 'invoicing'), |
|
| 384 | 384 | 'defaults' => array( |
| 385 | 385 | 'value' => '', |
| 386 | 386 | 'class' => 'btn-primary', |
| 387 | - 'label' => __( 'Pay %price% »', 'invoicing' ), |
|
| 388 | - 'free' => __( 'Continue »', 'invoicing' ), |
|
| 389 | - 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
| 387 | + 'label' => __('Pay %price% »', 'invoicing'), |
|
| 388 | + 'free' => __('Continue »', 'invoicing'), |
|
| 389 | + 'description' => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
| 390 | 390 | 'premade' => true, |
| 391 | 391 | ) |
| 392 | 392 | ), |
| 393 | 393 | |
| 394 | 394 | array( |
| 395 | 395 | 'type' => 'gateway_select', |
| 396 | - 'name' => __( 'Gateway Select', 'invoicing' ), |
|
| 396 | + 'name' => __('Gateway Select', 'invoicing'), |
|
| 397 | 397 | 'defaults' => array( |
| 398 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 398 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
| 399 | 399 | 'premade' => true, |
| 400 | 400 | ) |
| 401 | 401 | ), |
| 402 | 402 | |
| 403 | 403 | array( |
| 404 | 404 | 'type' => 'total_payable', |
| 405 | - 'name' => __( 'Total Payable', 'invoicing' ), |
|
| 405 | + 'name' => __('Total Payable', 'invoicing'), |
|
| 406 | 406 | 'defaults' => array( |
| 407 | - 'text' => __( 'Total to pay:', 'invoicing' ), |
|
| 407 | + 'text' => __('Total to pay:', 'invoicing'), |
|
| 408 | 408 | ) |
| 409 | 409 | ), |
| 410 | 410 | |
| 411 | 411 | array( |
| 412 | 412 | 'type' => 'ip_address', |
| 413 | - 'name' => __( 'IP Address', 'invoicing' ), |
|
| 413 | + 'name' => __('IP Address', 'invoicing'), |
|
| 414 | 414 | 'defaults' => array( |
| 415 | - 'text' => __( 'Your IP address is:', 'invoicing' ), |
|
| 415 | + 'text' => __('Your IP address is:', 'invoicing'), |
|
| 416 | 416 | ) |
| 417 | 417 | ) |
| 418 | 418 | ); |
@@ -1,32 +1,32 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - // Is the request set up correctly? |
|
| 4 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 5 | - return aui()->alert( |
|
| 6 | - array( |
|
| 7 | - 'type' => 'warning', |
|
| 8 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 9 | - ) |
|
| 10 | - ); |
|
| 11 | - wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - // Payment form or button? |
|
| 15 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 16 | - |
|
| 17 | - $shortcode = sprintf( |
|
| 18 | - '[getpaid form=%s]', |
|
| 19 | - (int) urldecode( $_GET['form'] ) |
|
| 20 | - ); |
|
| 21 | - |
|
| 22 | - } else { |
|
| 23 | - |
|
| 24 | - $shortcode = sprintf( |
|
| 25 | - '[getpaid item=%s]', |
|
| 26 | - esc_attr( urldecode( $_GET['item'] ) ) |
|
| 27 | - ); |
|
| 28 | - |
|
| 29 | - } |
|
| 3 | + // Is the request set up correctly? |
|
| 4 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 5 | + return aui()->alert( |
|
| 6 | + array( |
|
| 7 | + 'type' => 'warning', |
|
| 8 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 9 | + ) |
|
| 10 | + ); |
|
| 11 | + wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + // Payment form or button? |
|
| 15 | + if ( ! empty( $_GET['form'] ) ) { |
|
| 16 | + |
|
| 17 | + $shortcode = sprintf( |
|
| 18 | + '[getpaid form=%s]', |
|
| 19 | + (int) urldecode( $_GET['form'] ) |
|
| 20 | + ); |
|
| 21 | + |
|
| 22 | + } else { |
|
| 23 | + |
|
| 24 | + $shortcode = sprintf( |
|
| 25 | + '[getpaid item=%s]', |
|
| 26 | + esc_attr( urldecode( $_GET['item'] ) ) |
|
| 27 | + ); |
|
| 28 | + |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | ?> |
| 32 | 32 | |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | <title>GetPaid</title> |
| 46 | 46 | <?php |
| 47 | - wp_enqueue_scripts(); |
|
| 48 | - wp_print_styles(); |
|
| 49 | - wp_print_head_scripts(); |
|
| 50 | - wp_custom_css_cb(); |
|
| 51 | - wpinv_get_template( 'frontend-head.php' ); |
|
| 52 | - ?> |
|
| 47 | + wp_enqueue_scripts(); |
|
| 48 | + wp_print_styles(); |
|
| 49 | + wp_print_head_scripts(); |
|
| 50 | + wp_custom_css_cb(); |
|
| 51 | + wpinv_get_template( 'frontend-head.php' ); |
|
| 52 | + ?> |
|
| 53 | 53 | |
| 54 | 54 | <style type="text/css"> |
| 55 | 55 | .body{ |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | <body class="body page-template-default page"> |
| 84 | 84 | <div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content"> |
| 85 | 85 | <?php |
| 86 | - do_action( 'getpaid_payment_form_embed_top' ); |
|
| 87 | - echo do_shortcode( $shortcode ); |
|
| 88 | - do_action( 'getpaid_payment_form_embed_bottom' ); |
|
| 89 | - wpinv_get_template( 'frontend-footer.php' ); |
|
| 90 | - ?> |
|
| 86 | + do_action( 'getpaid_payment_form_embed_top' ); |
|
| 87 | + echo do_shortcode( $shortcode ); |
|
| 88 | + do_action( 'getpaid_payment_form_embed_bottom' ); |
|
| 89 | + wpinv_get_template( 'frontend-footer.php' ); |
|
| 90 | + ?> |
|
| 91 | 91 | </div> |
| 92 | 92 | <?php wp_footer(); ?> |
| 93 | 93 | </body> |
@@ -1,29 +1,29 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Is the request set up correctly? |
| 4 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 4 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
| 5 | 5 | return aui()->alert( |
| 6 | 6 | array( |
| 7 | 7 | 'type' => 'warning', |
| 8 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 8 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
| 9 | 9 | ) |
| 10 | 10 | ); |
| 11 | - wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
| 11 | + wp_die(__('No payment form or item selected', 'invoicing'), 400); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Payment form or button? |
| 15 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 15 | + if (!empty($_GET['form'])) { |
|
| 16 | 16 | |
| 17 | 17 | $shortcode = sprintf( |
| 18 | 18 | '[getpaid form=%s]', |
| 19 | - (int) urldecode( $_GET['form'] ) |
|
| 19 | + (int) urldecode($_GET['form']) |
|
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | 22 | } else { |
| 23 | 23 | |
| 24 | 24 | $shortcode = sprintf( |
| 25 | 25 | '[getpaid item=%s]', |
| 26 | - esc_attr( urldecode( $_GET['item'] ) ) |
|
| 26 | + esc_attr(urldecode($_GET['item'])) |
|
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | <head> |
| 37 | 37 | |
| 38 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 38 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 39 | 39 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
| 40 | 40 | |
| 41 | 41 | <meta name="robots" content="noindex,nofollow"> |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | wp_print_styles(); |
| 49 | 49 | wp_print_head_scripts(); |
| 50 | 50 | wp_custom_css_cb(); |
| 51 | - wpinv_get_template( 'frontend-head.php' ); |
|
| 51 | + wpinv_get_template('frontend-head.php'); |
|
| 52 | 52 | ?> |
| 53 | 53 | |
| 54 | 54 | <style type="text/css"> |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | <body class="body page-template-default page"> |
| 84 | 84 | <div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content"> |
| 85 | 85 | <?php |
| 86 | - do_action( 'getpaid_payment_form_embed_top' ); |
|
| 87 | - echo do_shortcode( $shortcode ); |
|
| 88 | - do_action( 'getpaid_payment_form_embed_bottom' ); |
|
| 89 | - wpinv_get_template( 'frontend-footer.php' ); |
|
| 86 | + do_action('getpaid_payment_form_embed_top'); |
|
| 87 | + echo do_shortcode($shortcode); |
|
| 88 | + do_action('getpaid_payment_form_embed_bottom'); |
|
| 89 | + wpinv_get_template('frontend-footer.php'); |
|
| 90 | 90 | ?> |
| 91 | 91 | </div> |
| 92 | 92 | <?php wp_footer(); ?> |