@@ -16,23 +16,23 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function __construct() { |
| 18 | 18 | |
| 19 | - $forms = get_posts( |
|
| 20 | - array( |
|
| 21 | - 'post_type' => 'wpi_payment_form', |
|
| 22 | - 'orderby' => 'title', |
|
| 23 | - 'order' => 'ASC', |
|
| 24 | - 'posts_per_page' => -1, |
|
| 25 | - 'post_status' => array( 'publish' ), |
|
| 26 | - ) |
|
| 27 | - ); |
|
| 28 | - |
|
| 29 | - $options = array( |
|
| 30 | - '' => __('Select a Form','invoicing') |
|
| 31 | - ); |
|
| 32 | - |
|
| 33 | - foreach( $forms as $form ) { |
|
| 34 | - $options[ $form->ID ] = $form->post_title; |
|
| 35 | - } |
|
| 19 | + $forms = get_posts( |
|
| 20 | + array( |
|
| 21 | + 'post_type' => 'wpi_payment_form', |
|
| 22 | + 'orderby' => 'title', |
|
| 23 | + 'order' => 'ASC', |
|
| 24 | + 'posts_per_page' => -1, |
|
| 25 | + 'post_status' => array( 'publish' ), |
|
| 26 | + ) |
|
| 27 | + ); |
|
| 28 | + |
|
| 29 | + $options = array( |
|
| 30 | + '' => __('Select a Form','invoicing') |
|
| 31 | + ); |
|
| 32 | + |
|
| 33 | + foreach( $forms as $form ) { |
|
| 34 | + $options[ $form->ID ] = $form->post_title; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | $options = array( |
| 38 | 38 | 'textdomain' => 'invoicing', |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | 'form' => array( |
| 51 | 51 | 'title' => __( 'Payment Form', 'invoicing' ), |
| 52 | 52 | 'desc' => __( 'Select your payment form.', 'invoicing' ), |
| 53 | - 'type' => 'select', |
|
| 54 | - 'options' => $options, |
|
| 53 | + 'type' => 'select', |
|
| 54 | + 'options' => $options, |
|
| 55 | 55 | 'desc_tip' => true, |
| 56 | 56 | 'default' => '', |
| 57 | 57 | 'advanced' => false |
@@ -64,59 +64,59 @@ discard block |
||
| 64 | 64 | parent::__construct( $options ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * The Super block output function. |
|
| 69 | - * |
|
| 70 | - * @param array $args |
|
| 71 | - * @param array $widget_args |
|
| 72 | - * @param string $content |
|
| 73 | - * |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 67 | + /** |
|
| 68 | + * The Super block output function. |
|
| 69 | + * |
|
| 70 | + * @param array $args |
|
| 71 | + * @param array $widget_args |
|
| 72 | + * @param string $content |
|
| 73 | + * |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | 76 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 77 | - global $invoicing; |
|
| 78 | - |
|
| 79 | - // Do we have a payment form? |
|
| 80 | - if ( empty( $args['form'] ) ) { |
|
| 81 | - return aui()->alert( |
|
| 82 | - array( |
|
| 83 | - 'type' => 'warning', |
|
| 84 | - 'content' => __( 'No payment form selected', 'invoicing' ), |
|
| 85 | - ) |
|
| 86 | - ); |
|
| 87 | - |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - // If yes, ensure that it is published. |
|
| 91 | - if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
| 92 | - return aui()->alert( |
|
| 93 | - array( |
|
| 94 | - 'type' => 'warning', |
|
| 95 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 96 | - ) |
|
| 97 | - ); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // Get the form elements and items. |
|
| 101 | - $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
| 102 | - $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
| 103 | - |
|
| 104 | - ob_start(); |
|
| 105 | - echo "<form class='wpinv_payment_form'>"; |
|
| 106 | - echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
|
| 107 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 108 | - |
|
| 109 | - foreach ( $elements as $element ) { |
|
| 110 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
| 111 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
| 115 | - echo '</form>'; |
|
| 116 | - |
|
| 117 | - $content = ob_get_clean(); |
|
| 77 | + global $invoicing; |
|
| 78 | + |
|
| 79 | + // Do we have a payment form? |
|
| 80 | + if ( empty( $args['form'] ) ) { |
|
| 81 | + return aui()->alert( |
|
| 82 | + array( |
|
| 83 | + 'type' => 'warning', |
|
| 84 | + 'content' => __( 'No payment form selected', 'invoicing' ), |
|
| 85 | + ) |
|
| 86 | + ); |
|
| 87 | + |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + // If yes, ensure that it is published. |
|
| 91 | + if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
| 92 | + return aui()->alert( |
|
| 93 | + array( |
|
| 94 | + 'type' => 'warning', |
|
| 95 | + 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 96 | + ) |
|
| 97 | + ); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // Get the form elements and items. |
|
| 101 | + $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
| 102 | + $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
| 103 | + |
|
| 104 | + ob_start(); |
|
| 105 | + echo "<form class='wpinv_payment_form'>"; |
|
| 106 | + echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
|
| 107 | + wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 108 | + |
|
| 109 | + foreach ( $elements as $element ) { |
|
| 110 | + do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
| 111 | + do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
| 115 | + echo '</form>'; |
|
| 116 | + |
|
| 117 | + $content = ob_get_clean(); |
|
| 118 | 118 | |
| 119 | - return str_replace( 'sr-only', '', $content ); |
|
| 119 | + return str_replace( 'sr-only', '', $content ); |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | 'orderby' => 'title', |
| 23 | 23 | 'order' => 'ASC', |
| 24 | 24 | 'posts_per_page' => -1, |
| 25 | - 'post_status' => array( 'publish' ), |
|
| 25 | + 'post_status' => array('publish'), |
|
| 26 | 26 | ) |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | $options = array( |
| 30 | - '' => __('Select a Form','invoicing') |
|
| 30 | + '' => __('Select a Form', 'invoicing') |
|
| 31 | 31 | ); |
| 32 | 32 | |
| 33 | - foreach( $forms as $form ) { |
|
| 34 | - $options[ $form->ID ] = $form->post_title; |
|
| 33 | + foreach ($forms as $form) { |
|
| 34 | + $options[$form->ID] = $form->post_title; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $options = array( |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | 'block-keywords'=> "['invoicing','buy', 'buy item', 'pay', 'payment form']", |
| 42 | 42 | 'class_name' => __CLASS__, |
| 43 | 43 | 'base_id' => 'wpinv_payment_form', |
| 44 | - 'name' => __('Invoicing > Payment Form','invoicing'), |
|
| 44 | + 'name' => __('Invoicing > Payment Form', 'invoicing'), |
|
| 45 | 45 | 'widget_ops' => array( |
| 46 | 46 | 'classname' => 'wpinv-payment-form-class bsui', |
| 47 | - 'description' => esc_html__('Displays a payment form.','invoicing'), |
|
| 47 | + 'description' => esc_html__('Displays a payment form.', 'invoicing'), |
|
| 48 | 48 | ), |
| 49 | 49 | 'arguments' => array( |
| 50 | 50 | 'form' => array( |
| 51 | - 'title' => __( 'Payment Form', 'invoicing' ), |
|
| 52 | - 'desc' => __( 'Select your payment form.', 'invoicing' ), |
|
| 51 | + 'title' => __('Payment Form', 'invoicing'), |
|
| 52 | + 'desc' => __('Select your payment form.', 'invoicing'), |
|
| 53 | 53 | 'type' => 'select', |
| 54 | 54 | 'options' => $options, |
| 55 | 55 | 'desc_tip' => true, |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | |
| 64 | - parent::__construct( $options ); |
|
| 64 | + parent::__construct($options); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -73,42 +73,42 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 76 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 77 | 77 | global $invoicing; |
| 78 | 78 | |
| 79 | 79 | // Do we have a payment form? |
| 80 | - if ( empty( $args['form'] ) ) { |
|
| 80 | + if (empty($args['form'])) { |
|
| 81 | 81 | return aui()->alert( |
| 82 | 82 | array( |
| 83 | 83 | 'type' => 'warning', |
| 84 | - 'content' => __( 'No payment form selected', 'invoicing' ), |
|
| 84 | + 'content' => __('No payment form selected', 'invoicing'), |
|
| 85 | 85 | ) |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // If yes, ensure that it is published. |
| 91 | - if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
| 91 | + if ('publish' != get_post_status($args['form'])) { |
|
| 92 | 92 | return aui()->alert( |
| 93 | 93 | array( |
| 94 | 94 | 'type' => 'warning', |
| 95 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
| 95 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
| 96 | 96 | ) |
| 97 | 97 | ); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Get the form elements and items. |
| 101 | - $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
| 102 | - $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
| 101 | + $elements = $invoicing->form_elements->get_form_elements($args['form']); |
|
| 102 | + $items = $invoicing->form_elements->get_form_items($args['form']); |
|
| 103 | 103 | |
| 104 | 104 | ob_start(); |
| 105 | 105 | echo "<form class='wpinv_payment_form'>"; |
| 106 | 106 | echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
| 107 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
| 107 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
| 108 | 108 | |
| 109 | - foreach ( $elements as $element ) { |
|
| 110 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
| 111 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
| 109 | + foreach ($elements as $element) { |
|
| 110 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $args['form']); |
|
| 111 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form']); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $content = ob_get_clean(); |
| 118 | 118 | |
| 119 | - return str_replace( 'sr-only', '', $content ); |
|
| 119 | + return str_replace('sr-only', '', $content); |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | |
@@ -7,28 +7,28 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Ajax { |
| 15 | 15 | public static function init() { |
| 16 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
| 17 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
| 16 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
| 17 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
| 18 | 18 | self::add_ajax_events(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public static function define_ajax() { |
| 22 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
| 23 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
| 24 | - define( 'DOING_AJAX', true ); |
|
| 22 | + if (!empty($_GET['wpinv-ajax'])) { |
|
| 23 | + if (!defined('DOING_AJAX')) { |
|
| 24 | + define('DOING_AJAX', true); |
|
| 25 | 25 | } |
| 26 | - if ( ! defined( 'WC_DOING_AJAX' ) ) { |
|
| 27 | - define( 'WC_DOING_AJAX', true ); |
|
| 26 | + if (!defined('WC_DOING_AJAX')) { |
|
| 27 | + define('WC_DOING_AJAX', true); |
|
| 28 | 28 | } |
| 29 | 29 | // Turn off display_errors during AJAX events to prevent malformed JSON |
| 30 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
| 31 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
| 30 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
| 31 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
| 32 | 32 | } |
| 33 | 33 | $GLOBALS['wpdb']->hide_errors(); |
| 34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
| 37 | 37 | public static function do_wpinv_ajax() { |
| 38 | 38 | global $wp_query; |
| 39 | 39 | |
| 40 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
| 41 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) ); |
|
| 40 | + if (!empty($_GET['wpinv-ajax'])) { |
|
| 41 | + $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax'])); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( $action = $wp_query->get( 'wpinv-ajax' ) ) { |
|
| 44 | + if ($action = $wp_query->get('wpinv-ajax')) { |
|
| 45 | 45 | self::wpinv_ajax_headers(); |
| 46 | - do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) ); |
|
| 46 | + do_action('wpinv_ajax_' . sanitize_text_field($action)); |
|
| 47 | 47 | die(); |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | private static function wpinv_ajax_headers() { |
| 52 | 52 | send_origin_headers(); |
| 53 | - /** @scrutinizer ignore-unhandled */ @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
| 54 | - /** @scrutinizer ignore-unhandled */ @header( 'X-Robots-Tag: noindex' ); |
|
| 53 | + /** @scrutinizer ignore-unhandled */ @header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
| 54 | + /** @scrutinizer ignore-unhandled */ @header('X-Robots-Tag: noindex'); |
|
| 55 | 55 | send_nosniff_header(); |
| 56 | 56 | nocache_headers(); |
| 57 | - status_header( 200 ); |
|
| 57 | + status_header(200); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public static function add_ajax_events() { |
@@ -78,39 +78,39 @@ discard block |
||
| 78 | 78 | 'buy_items' => true, |
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
| 82 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 81 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
| 82 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 83 | 83 | |
| 84 | - if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) { |
|
| 85 | - define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 ); |
|
| 84 | + if (!defined('WPI_AJAX_' . strtoupper($nopriv))) { |
|
| 85 | + define('WPI_AJAX_' . strtoupper($nopriv), 1); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ( $nopriv ) { |
|
| 89 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 88 | + if ($nopriv) { |
|
| 89 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 90 | 90 | |
| 91 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
| 91 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public static function add_note() { |
| 97 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
| 97 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
| 98 | 98 | |
| 99 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 99 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 100 | 100 | die(-1); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $post_id = absint( $_POST['post_id'] ); |
|
| 104 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
| 105 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
| 103 | + $post_id = absint($_POST['post_id']); |
|
| 104 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
| 105 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
| 106 | 106 | |
| 107 | 107 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
| 108 | 108 | |
| 109 | - if ( $post_id > 0 ) { |
|
| 110 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
| 109 | + if ($post_id > 0) { |
|
| 110 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
| 111 | 111 | |
| 112 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
| 113 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
| 112 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
| 113 | + wpinv_get_invoice_note_line_item($note_id); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public static function delete_note() { |
| 121 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
| 121 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
| 122 | 122 | |
| 123 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 123 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 124 | 124 | die(-1); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $note_id = (int)$_POST['note_id']; |
|
| 127 | + $note_id = (int) $_POST['note_id']; |
|
| 128 | 128 | |
| 129 | - if ( $note_id > 0 ) { |
|
| 130 | - wp_delete_comment( $note_id, true ); |
|
| 129 | + if ($note_id > 0) { |
|
| 130 | + wp_delete_comment($note_id, true); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | die(); |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public static function checkout() { |
| 143 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
| 144 | - define( 'WPINV_CHECKOUT', true ); |
|
| 143 | + if (!defined('WPINV_CHECKOUT')) { |
|
| 144 | + define('WPINV_CHECKOUT', true); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | wpinv_process_checkout(); |
@@ -150,53 +150,53 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | public static function add_invoice_item() { |
| 152 | 152 | global $wpi_userID, $wpinv_ip_address_country; |
| 153 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
| 154 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 153 | + check_ajax_referer('invoice-item', '_nonce'); |
|
| 154 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 155 | 155 | die(-1); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
| 159 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 158 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
| 159 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 160 | 160 | |
| 161 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
| 161 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
| 162 | 162 | die(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 166 | - if ( empty( $invoice ) ) { |
|
| 165 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 166 | + if (empty($invoice)) { |
|
| 167 | 167 | die(); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 170 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 171 | 171 | die(); // Don't allow modify items for paid invoice. |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( !empty( $_POST['user_id'] ) ) { |
|
| 175 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
| 174 | + if (!empty($_POST['user_id'])) { |
|
| 175 | + $wpi_userID = absint($_POST['user_id']); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $item = new WPInv_Item( $item_id ); |
|
| 179 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
| 178 | + $item = new WPInv_Item($item_id); |
|
| 179 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
| 180 | 180 | die(); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Validate item before adding to invoice because recurring item must be paid individually. |
| 184 | - if ( !empty( $invoice->cart_details ) ) { |
|
| 184 | + if (!empty($invoice->cart_details)) { |
|
| 185 | 185 | $valid = true; |
| 186 | 186 | |
| 187 | - if ( $recurring_item = $invoice->get_recurring() ) { |
|
| 188 | - if ( $recurring_item != $item_id ) { |
|
| 187 | + if ($recurring_item = $invoice->get_recurring()) { |
|
| 188 | + if ($recurring_item != $item_id) { |
|
| 189 | 189 | $valid = false; |
| 190 | 190 | } |
| 191 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
| 191 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
| 192 | 192 | $valid = false; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if ( !$valid ) { |
|
| 195 | + if (!$valid) { |
|
| 196 | 196 | $response = array(); |
| 197 | 197 | $response['success'] = false; |
| 198 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
| 199 | - wp_send_json( $response ); |
|
| 198 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
| 199 | + wp_send_json($response); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
@@ -204,11 +204,11 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $data = array(); |
| 206 | 206 | $data['invoice_id'] = $invoice_id; |
| 207 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 207 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 208 | 208 | |
| 209 | - wpinv_set_checkout_session( $data ); |
|
| 209 | + wpinv_set_checkout_session($data); |
|
| 210 | 210 | |
| 211 | - $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1; |
|
| 211 | + $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1; |
|
| 212 | 212 | |
| 213 | 213 | $args = array( |
| 214 | 214 | 'id' => $item_id, |
@@ -221,21 +221,21 @@ discard block |
||
| 221 | 221 | 'fees' => array() |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | - $invoice->add_item( $item_id, $args ); |
|
| 224 | + $invoice->add_item($item_id, $args); |
|
| 225 | 225 | $invoice->save(); |
| 226 | 226 | |
| 227 | - if ( empty( $_POST['country'] ) ) { |
|
| 227 | + if (empty($_POST['country'])) { |
|
| 228 | 228 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
| 229 | 229 | } |
| 230 | - if ( empty( $_POST['state'] ) ) { |
|
| 230 | + if (empty($_POST['state'])) { |
|
| 231 | 231 | $_POST['state'] = $invoice->state; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
| 235 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
| 234 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
| 235 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
| 236 | 236 | |
| 237 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 238 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 237 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 238 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 239 | 239 | |
| 240 | 240 | $wpinv_ip_address_country = $invoice->country; |
| 241 | 241 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $response = array(); |
| 245 | 245 | $response['success'] = true; |
| 246 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
| 246 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
| 247 | 247 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 248 | 248 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
| 249 | 249 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -255,41 +255,41 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | wpinv_set_checkout_session($checkout_session); |
| 257 | 257 | |
| 258 | - wp_send_json( $response ); |
|
| 258 | + wp_send_json($response); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | public static function remove_invoice_item() { |
| 263 | 263 | global $wpi_userID, $wpinv_ip_address_country; |
| 264 | 264 | |
| 265 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
| 266 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 265 | + check_ajax_referer('invoice-item', '_nonce'); |
|
| 266 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 267 | 267 | die(-1); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
| 271 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 272 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
| 270 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
| 271 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 272 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
| 273 | 273 | |
| 274 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
| 274 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
| 275 | 275 | die(); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 279 | - if ( empty( $invoice ) ) { |
|
| 278 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 279 | + if (empty($invoice)) { |
|
| 280 | 280 | die(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 283 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 284 | 284 | die(); // Don't allow modify items for paid invoice. |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if ( !empty( $_POST['user_id'] ) ) { |
|
| 288 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
| 287 | + if (!empty($_POST['user_id'])) { |
|
| 288 | + $wpi_userID = absint($_POST['user_id']); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $item = new WPInv_Item( $item_id ); |
|
| 292 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
| 291 | + $item = new WPInv_Item($item_id); |
|
| 292 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
| 293 | 293 | die(); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | $data = array(); |
| 299 | 299 | $data['invoice_id'] = $invoice_id; |
| 300 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 300 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 301 | 301 | |
| 302 | - wpinv_set_checkout_session( $data ); |
|
| 302 | + wpinv_set_checkout_session($data); |
|
| 303 | 303 | |
| 304 | 304 | $args = array( |
| 305 | 305 | 'id' => $item_id, |
@@ -307,21 +307,21 @@ discard block |
||
| 307 | 307 | 'cart_index' => $cart_index |
| 308 | 308 | ); |
| 309 | 309 | |
| 310 | - $invoice->remove_item( $item_id, $args ); |
|
| 310 | + $invoice->remove_item($item_id, $args); |
|
| 311 | 311 | $invoice->save(); |
| 312 | 312 | |
| 313 | - if ( empty( $_POST['country'] ) ) { |
|
| 313 | + if (empty($_POST['country'])) { |
|
| 314 | 314 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
| 315 | 315 | } |
| 316 | - if ( empty( $_POST['state'] ) ) { |
|
| 316 | + if (empty($_POST['state'])) { |
|
| 317 | 317 | $_POST['state'] = $invoice->state; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
| 321 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
| 320 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
| 321 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
| 322 | 322 | |
| 323 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 324 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 323 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 324 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 325 | 325 | |
| 326 | 326 | $wpinv_ip_address_country = $invoice->country; |
| 327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | $response = array(); |
| 331 | 331 | $response['success'] = true; |
| 332 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
| 332 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
| 333 | 333 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 334 | 334 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
| 335 | 335 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -341,55 +341,55 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | wpinv_set_checkout_session($checkout_session); |
| 343 | 343 | |
| 344 | - wp_send_json( $response ); |
|
| 344 | + wp_send_json($response); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | public static function create_invoice_item() { |
| 348 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
| 349 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 348 | + check_ajax_referer('invoice-item', '_nonce'); |
|
| 349 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 350 | 350 | die(-1); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 353 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 354 | 354 | |
| 355 | 355 | // Find the item |
| 356 | - if ( !is_numeric( $invoice_id ) ) { |
|
| 356 | + if (!is_numeric($invoice_id)) { |
|
| 357 | 357 | die(); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 361 | - if ( empty( $invoice ) ) { |
|
| 360 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 361 | + if (empty($invoice)) { |
|
| 362 | 362 | die(); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // Validate item before adding to invoice because recurring item must be paid individually. |
| 366 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
| 366 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
| 367 | 367 | $response = array(); |
| 368 | 368 | $response['success'] = false; |
| 369 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
| 370 | - wp_send_json( $response ); |
|
| 369 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
| 370 | + wp_send_json($response); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - $save_item = wp_unslash( $_POST['_wpinv_quick'] ); |
|
| 373 | + $save_item = wp_unslash($_POST['_wpinv_quick']); |
|
| 374 | 374 | |
| 375 | 375 | $meta = array(); |
| 376 | 376 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
| 377 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
| 377 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
| 378 | 378 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
| 379 | 379 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
| 380 | 380 | |
| 381 | 381 | $data = array(); |
| 382 | 382 | $data['post_title'] = sanitize_text_field($save_item['name']); |
| 383 | 383 | $data['post_status'] = 'publish'; |
| 384 | - $data['post_excerpt'] = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : ''; |
|
| 384 | + $data['post_excerpt'] = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : ''; |
|
| 385 | 385 | $data['meta'] = $meta; |
| 386 | 386 | |
| 387 | 387 | $item = new WPInv_Item(); |
| 388 | - $item->create( $data ); |
|
| 388 | + $item->create($data); |
|
| 389 | 389 | |
| 390 | - if ( !empty( $item ) ) { |
|
| 390 | + if (!empty($item)) { |
|
| 391 | 391 | $_POST['item_id'] = $item->ID; |
| 392 | - $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
|
| 392 | + $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1; |
|
| 393 | 393 | |
| 394 | 394 | self::add_invoice_item(); |
| 395 | 395 | } |
@@ -397,15 +397,15 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | public static function get_billing_details() { |
| 400 | - check_ajax_referer( 'get-billing-details', '_nonce' ); |
|
| 400 | + check_ajax_referer('get-billing-details', '_nonce'); |
|
| 401 | 401 | |
| 402 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 402 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 403 | 403 | die(-1); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - $user_id = (int)$_POST['user_id']; |
|
| 406 | + $user_id = (int) $_POST['user_id']; |
|
| 407 | 407 | $billing_details = wpinv_get_user_address($user_id); |
| 408 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
| 408 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
| 409 | 409 | |
| 410 | 410 | if (isset($billing_details['user_id'])) { |
| 411 | 411 | unset($billing_details['user_id']); |
@@ -419,20 +419,20 @@ discard block |
||
| 419 | 419 | $response['success'] = true; |
| 420 | 420 | $response['data']['billing_details'] = $billing_details; |
| 421 | 421 | |
| 422 | - wp_send_json( $response ); |
|
| 422 | + wp_send_json($response); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | public static function admin_recalculate_totals() { |
| 426 | 426 | global $wpi_userID, $wpinv_ip_address_country; |
| 427 | 427 | |
| 428 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 429 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 428 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 429 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 430 | 430 | die(-1); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 434 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 435 | - if ( empty( $invoice ) ) { |
|
| 433 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 434 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 435 | + if (empty($invoice)) { |
|
| 436 | 436 | die(); |
| 437 | 437 | } |
| 438 | 438 | |
@@ -440,23 +440,23 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | $data = array(); |
| 442 | 442 | $data['invoice_id'] = $invoice_id; |
| 443 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 443 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 444 | 444 | |
| 445 | - wpinv_set_checkout_session( $data ); |
|
| 445 | + wpinv_set_checkout_session($data); |
|
| 446 | 446 | |
| 447 | - if ( !empty( $_POST['user_id'] ) ) { |
|
| 448 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
| 447 | + if (!empty($_POST['user_id'])) { |
|
| 448 | + $wpi_userID = absint($_POST['user_id']); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - if ( empty( $_POST['country'] ) ) { |
|
| 451 | + if (empty($_POST['country'])) { |
|
| 452 | 452 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
| 456 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 457 | - if ( isset( $_POST['state'] ) ) { |
|
| 458 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
| 459 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 455 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
| 456 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 457 | + if (isset($_POST['state'])) { |
|
| 458 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
| 459 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | $wpinv_ip_address_country = $invoice->country; |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | $response = array(); |
| 467 | 467 | $response['success'] = true; |
| 468 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
| 468 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
| 469 | 469 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 470 | 470 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
| 471 | 471 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -477,25 +477,25 @@ discard block |
||
| 477 | 477 | |
| 478 | 478 | wpinv_set_checkout_session($checkout_session); |
| 479 | 479 | |
| 480 | - wp_send_json( $response ); |
|
| 480 | + wp_send_json($response); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | public static function admin_apply_discount() { |
| 484 | 484 | global $wpi_userID; |
| 485 | 485 | |
| 486 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 487 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 486 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 487 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 488 | 488 | die(-1); |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 492 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 493 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
| 491 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 492 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 493 | + if (empty($invoice_id) || empty($discount_code)) { |
|
| 494 | 494 | die(); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 498 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
| 497 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 498 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
| 499 | 499 | die(); |
| 500 | 500 | } |
| 501 | 501 | |
@@ -503,49 +503,49 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | $data = array(); |
| 505 | 505 | $data['invoice_id'] = $invoice_id; |
| 506 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 506 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 507 | 507 | |
| 508 | - wpinv_set_checkout_session( $data ); |
|
| 508 | + wpinv_set_checkout_session($data); |
|
| 509 | 509 | |
| 510 | 510 | $response = array(); |
| 511 | 511 | $response['success'] = false; |
| 512 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
| 512 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
| 513 | 513 | $response['data']['code'] = $discount_code; |
| 514 | 514 | |
| 515 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
| 516 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
| 515 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
| 516 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
| 517 | 517 | |
| 518 | 518 | $response['success'] = true; |
| 519 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
| 520 | - } else { |
|
| 519 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
| 520 | + } else { |
|
| 521 | 521 | $errors = wpinv_get_errors(); |
| 522 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
| 522 | + if (!empty($errors['wpinv-discount-error'])) { |
|
| 523 | 523 | $response['msg'] = $errors['wpinv-discount-error']; |
| 524 | 524 | } |
| 525 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
| 525 | + wpinv_unset_error('wpinv-discount-error'); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | wpinv_set_checkout_session($checkout_session); |
| 529 | 529 | |
| 530 | - wp_send_json( $response ); |
|
| 530 | + wp_send_json($response); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | public static function admin_remove_discount() { |
| 534 | 534 | global $wpi_userID; |
| 535 | 535 | |
| 536 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 537 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 536 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 537 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 538 | 538 | die(-1); |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
| 542 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 543 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
| 541 | + $invoice_id = absint($_POST['invoice_id']); |
|
| 542 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 543 | + if (empty($invoice_id) || empty($discount_code)) { |
|
| 544 | 544 | die(); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 548 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
| 547 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 548 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
| 549 | 549 | die(); |
| 550 | 550 | } |
| 551 | 551 | |
@@ -553,38 +553,38 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | $data = array(); |
| 555 | 555 | $data['invoice_id'] = $invoice_id; |
| 556 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 556 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 557 | 557 | |
| 558 | - wpinv_set_checkout_session( $data ); |
|
| 558 | + wpinv_set_checkout_session($data); |
|
| 559 | 559 | |
| 560 | 560 | $response = array(); |
| 561 | 561 | $response['success'] = false; |
| 562 | 562 | $response['msg'] = NULL; |
| 563 | 563 | |
| 564 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
| 564 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
| 565 | 565 | $response['success'] = true; |
| 566 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
| 566 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
| 567 | 567 | |
| 568 | 568 | wpinv_set_checkout_session($checkout_session); |
| 569 | 569 | |
| 570 | - wp_send_json( $response ); |
|
| 570 | + wp_send_json($response); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | public static function check_email() { |
| 574 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 575 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 574 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 575 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 576 | 576 | die(-1); |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - $email = sanitize_text_field( $_POST['email'] ); |
|
| 579 | + $email = sanitize_text_field($_POST['email']); |
|
| 580 | 580 | |
| 581 | 581 | $response = array(); |
| 582 | - if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) { |
|
| 582 | + if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) { |
|
| 583 | 583 | $user_id = $user_data->ID; |
| 584 | 584 | $user_login = $user_data->user_login; |
| 585 | 585 | $display_name = $user_data->display_name ? $user_data->display_name : $user_login; |
| 586 | 586 | $billing_details = wpinv_get_user_address($user_id); |
| 587 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
| 587 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
| 588 | 588 | |
| 589 | 589 | if (isset($billing_details['user_id'])) { |
| 590 | 590 | unset($billing_details['user_id']); |
@@ -600,54 +600,54 @@ discard block |
||
| 600 | 600 | $response['data']['billing_details'] = $billing_details; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - wp_send_json( $response ); |
|
| 603 | + wp_send_json($response); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | public static function run_tool() { |
| 607 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 608 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 607 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 608 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 609 | 609 | die(-1); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
| 612 | + $tool = sanitize_text_field($_POST['tool']); |
|
| 613 | 613 | |
| 614 | - do_action( 'wpinv_run_tool' ); |
|
| 614 | + do_action('wpinv_run_tool'); |
|
| 615 | 615 | |
| 616 | - if ( !empty( $tool ) ) { |
|
| 617 | - do_action( 'wpinv_tool_' . $tool ); |
|
| 616 | + if (!empty($tool)) { |
|
| 617 | + do_action('wpinv_tool_' . $tool); |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | public static function apply_discount() { |
| 622 | 622 | global $wpi_userID; |
| 623 | 623 | |
| 624 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 624 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 625 | 625 | |
| 626 | 626 | $response = array(); |
| 627 | 627 | |
| 628 | - if ( isset( $_POST['code'] ) ) { |
|
| 629 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 628 | + if (isset($_POST['code'])) { |
|
| 629 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 630 | 630 | |
| 631 | 631 | $response['success'] = false; |
| 632 | 632 | $response['msg'] = ''; |
| 633 | 633 | $response['data']['code'] = $discount_code; |
| 634 | 634 | |
| 635 | 635 | $invoice = wpinv_get_invoice_cart(); |
| 636 | - if ( empty( $invoice->ID ) ) { |
|
| 637 | - $response['msg'] = __( 'Invalid checkout request.', 'invoicing' ); |
|
| 638 | - wp_send_json( $response ); |
|
| 636 | + if (empty($invoice->ID)) { |
|
| 637 | + $response['msg'] = __('Invalid checkout request.', 'invoicing'); |
|
| 638 | + wp_send_json($response); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | $wpi_userID = $invoice->get_user_id(); |
| 642 | 642 | |
| 643 | - if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) { |
|
| 644 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
| 645 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
| 646 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
| 647 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
| 648 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
| 643 | + if (wpinv_is_discount_valid($discount_code, $wpi_userID)) { |
|
| 644 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
| 645 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
| 646 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
| 647 | + $total = wpinv_get_cart_total(null, $discounts); |
|
| 648 | + $cart_totals = wpinv_recalculate_tax(true); |
|
| 649 | 649 | |
| 650 | - if ( !empty( $cart_totals ) ) { |
|
| 650 | + if (!empty($cart_totals)) { |
|
| 651 | 651 | $response['success'] = true; |
| 652 | 652 | $response['data'] = $cart_totals; |
| 653 | 653 | $response['data']['code'] = $discount_code; |
@@ -656,29 +656,29 @@ discard block |
||
| 656 | 656 | } |
| 657 | 657 | } else { |
| 658 | 658 | $errors = wpinv_get_errors(); |
| 659 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
| 660 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
| 659 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
| 660 | + wpinv_unset_error('wpinv-discount-error'); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | // Allow for custom discount code handling |
| 664 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
| 664 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - wp_send_json( $response ); |
|
| 667 | + wp_send_json($response); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | public static function remove_discount() { |
| 671 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
| 671 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
| 672 | 672 | |
| 673 | 673 | $response = array(); |
| 674 | 674 | |
| 675 | - if ( isset( $_POST['code'] ) ) { |
|
| 676 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
| 677 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
| 678 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
| 679 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
| 675 | + if (isset($_POST['code'])) { |
|
| 676 | + $discount_code = sanitize_text_field($_POST['code']); |
|
| 677 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
| 678 | + $total = wpinv_get_cart_total(null, $discounts); |
|
| 679 | + $cart_totals = wpinv_recalculate_tax(true); |
|
| 680 | 680 | |
| 681 | - if ( !empty( $cart_totals ) ) { |
|
| 681 | + if (!empty($cart_totals)) { |
|
| 682 | 682 | $response['success'] = true; |
| 683 | 683 | $response['data'] = $cart_totals; |
| 684 | 684 | $response['data']['code'] = $discount_code; |
@@ -687,10 +687,10 @@ discard block |
||
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | // Allow for custom discount code handling |
| 690 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
| 690 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - wp_send_json( $response ); |
|
| 693 | + wp_send_json($response); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
@@ -702,66 +702,66 @@ discard block |
||
| 702 | 702 | global $invoicing; |
| 703 | 703 | |
| 704 | 704 | // Check nonce. |
| 705 | - if ( ! isset( $_POST['wpinv_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_payment_form'], 'wpinv_payment_form' ) ) { |
|
| 706 | - wp_send_json_error( __( 'Security checks failed.', 'invoicing' ) ); |
|
| 705 | + if (!isset($_POST['wpinv_payment_form']) || !wp_verify_nonce($_POST['wpinv_payment_form'], 'wpinv_payment_form')) { |
|
| 706 | + wp_send_json_error(__('Security checks failed.', 'invoicing')); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | // Prepare submitted data... |
| 710 | - $data = wp_unslash( $_POST ); |
|
| 710 | + $data = wp_unslash($_POST); |
|
| 711 | 711 | $prepared = array(); |
| 712 | 712 | |
| 713 | 713 | // ... form fields... |
| 714 | - if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) { |
|
| 715 | - wp_send_json_error( __( 'This payment form is no longer active.', 'invoicing' ) ); |
|
| 714 | + if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) { |
|
| 715 | + wp_send_json_error(__('This payment form is no longer active.', 'invoicing')); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - if ( empty( $data['billing_email'] ) || ! is_email( $data['billing_email'] ) ) { |
|
| 719 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
| 718 | + if (empty($data['billing_email']) || !is_email($data['billing_email'])) { |
|
| 719 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $prepared['billing_email'] = sanitize_email( $data['billing_email'] ); |
|
| 722 | + $prepared['billing_email'] = sanitize_email($data['billing_email']); |
|
| 723 | 723 | |
| 724 | - $fields = $invoicing->form_elements->get_form_elements( $data['form_id'] ); |
|
| 724 | + $fields = $invoicing->form_elements->get_form_elements($data['form_id']); |
|
| 725 | 725 | |
| 726 | 726 | // ... and form items. |
| 727 | - $items = $invoicing->form_elements->get_form_items( $data['form_id'] ); |
|
| 727 | + $items = $invoicing->form_elements->get_form_items($data['form_id']); |
|
| 728 | 728 | $prepared_items = array(); |
| 729 | 729 | |
| 730 | - foreach( $items as $item ) { |
|
| 730 | + foreach ($items as $item) { |
|
| 731 | 731 | $prepared_items[] = array( |
| 732 | 732 | 'id' => $item['id'], |
| 733 | - 'item_price' => wpinv_sanitize_amount( $item['price'] ), |
|
| 734 | - 'custom_price' => wpinv_sanitize_amount( $item['price'] ), |
|
| 733 | + 'item_price' => wpinv_sanitize_amount($item['price']), |
|
| 734 | + 'custom_price' => wpinv_sanitize_amount($item['price']), |
|
| 735 | 735 | 'name' => $item['title'], |
| 736 | 736 | ); |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | // Are all required fields provided? |
| 740 | - foreach ( $fields as $field ) { |
|
| 740 | + foreach ($fields as $field) { |
|
| 741 | 741 | |
| 742 | - if ( ! empty( $field['premade'] ) ) { |
|
| 742 | + if (!empty($field['premade'])) { |
|
| 743 | 743 | continue; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if ( ! empty( $field['required'] ) && empty( $data[ $field['id'] ] ) ) { |
|
| 747 | - wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) ); |
|
| 746 | + if (!empty($field['required']) && empty($data[$field['id']])) { |
|
| 747 | + wp_send_json_error(__('Some required fields have not been filled.', 'invoicing')); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - $prepared[ $field['id'] ] = wpinv_clean( $data[ $field['id'] ] ); |
|
| 750 | + $prepared[$field['id']] = wpinv_clean($data[$field['id']]); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - $user = get_user_by( 'email', $prepared['billing_email'] ); |
|
| 753 | + $user = get_user_by('email', $prepared['billing_email']); |
|
| 754 | 754 | |
| 755 | - if ( empty( $user ) ) { |
|
| 756 | - $user = wpinv_create_user( $prepared['billing_email'] ); |
|
| 755 | + if (empty($user)) { |
|
| 756 | + $user = wpinv_create_user($prepared['billing_email']); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | - if ( is_wp_error( $user ) ) { |
|
| 760 | - wp_send_json_error( $user->get_error_message() ); |
|
| 759 | + if (is_wp_error($user)) { |
|
| 760 | + wp_send_json_error($user->get_error_message()); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - if ( is_numeric( $user ) ) { |
|
| 764 | - $user = get_user_by( 'id', $user ); |
|
| 763 | + if (is_numeric($user)) { |
|
| 764 | + $user = get_user_by('id', $user); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | // Create the invoice. |
@@ -775,15 +775,15 @@ discard block |
||
| 775 | 775 | true |
| 776 | 776 | ); |
| 777 | 777 | |
| 778 | - if ( is_wp_error( $created ) ) { |
|
| 779 | - wp_send_json_error( $created->get_error_message() ); |
|
| 778 | + if (is_wp_error($created)) { |
|
| 779 | + wp_send_json_error($created->get_error_message()); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - if ( empty( $created ) ) { |
|
| 783 | - wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) ); |
|
| 782 | + if (empty($created)) { |
|
| 783 | + wp_send_json_error(__('Could not create your invoice.', 'invoicing')); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - wp_send_json_success( $created->get_view_url( true ) ); |
|
| 786 | + wp_send_json_success($created->get_view_url(true)); |
|
| 787 | 787 | |
| 788 | 788 | } |
| 789 | 789 | |
@@ -795,53 +795,53 @@ discard block |
||
| 795 | 795 | public static function buy_items() { |
| 796 | 796 | $user_id = get_current_user_id(); |
| 797 | 797 | |
| 798 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
| 799 | - wp_send_json( array( |
|
| 800 | - 'success' => wp_login_url( wp_get_referer() ) |
|
| 801 | - ) ); |
|
| 798 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
| 799 | + wp_send_json(array( |
|
| 800 | + 'success' => wp_login_url(wp_get_referer()) |
|
| 801 | + )); |
|
| 802 | 802 | } else { |
| 803 | 803 | // Only check nonce if logged in as it could be cached when logged out. |
| 804 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
| 805 | - wp_send_json( array( |
|
| 806 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
| 807 | - ) ); |
|
| 804 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
| 805 | + wp_send_json(array( |
|
| 806 | + 'error' => __('Security checks failed.', 'invoicing') |
|
| 807 | + )); |
|
| 808 | 808 | wp_die(); |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | // allow to set a custom price through post_id |
| 812 | 812 | $items = $_POST['items']; |
| 813 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
| 814 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
| 813 | + $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; |
|
| 814 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
| 815 | 815 | |
| 816 | 816 | $cart_items = array(); |
| 817 | - if ( $items ) { |
|
| 818 | - $items = explode( ',', $items ); |
|
| 817 | + if ($items) { |
|
| 818 | + $items = explode(',', $items); |
|
| 819 | 819 | |
| 820 | - foreach( $items as $item ) { |
|
| 820 | + foreach ($items as $item) { |
|
| 821 | 821 | $item_id = $item; |
| 822 | 822 | $quantity = 1; |
| 823 | 823 | |
| 824 | - if ( strpos( $item, '|' ) !== false ) { |
|
| 825 | - $item_parts = explode( '|', $item ); |
|
| 824 | + if (strpos($item, '|') !== false) { |
|
| 825 | + $item_parts = explode('|', $item); |
|
| 826 | 826 | $item_id = $item_parts[0]; |
| 827 | 827 | $quantity = $item_parts[1]; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - if ( $item_id && $quantity ) { |
|
| 830 | + if ($item_id && $quantity) { |
|
| 831 | 831 | $cart_items_arr = array( |
| 832 | - 'id' => (int)$item_id, |
|
| 833 | - 'quantity' => (int)$quantity |
|
| 832 | + 'id' => (int) $item_id, |
|
| 833 | + 'quantity' => (int) $quantity |
|
| 834 | 834 | ); |
| 835 | 835 | |
| 836 | 836 | // If there is a related post id then add it to meta |
| 837 | - if ( $related_post_id ) { |
|
| 837 | + if ($related_post_id) { |
|
| 838 | 838 | $cart_items_arr['meta'] = array( |
| 839 | 839 | 'post_id' => $related_post_id |
| 840 | 840 | ); |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | // If there is a custom price then set it. |
| 844 | - if ( $custom_item_price ) { |
|
| 844 | + if ($custom_item_price) { |
|
| 845 | 845 | $cart_items_arr['custom_price'] = $custom_item_price; |
| 846 | 846 | } |
| 847 | 847 | |
@@ -857,37 +857,37 @@ discard block |
||
| 857 | 857 | * @param int $related_post_id The related post id if any. |
| 858 | 858 | * @since 1.0.0 |
| 859 | 859 | */ |
| 860 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
| 860 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
| 861 | 861 | |
| 862 | 862 | // Make sure its not in the cart already, if it is then redirect to checkout. |
| 863 | 863 | $cart_invoice = wpinv_get_invoice_cart(); |
| 864 | 864 | |
| 865 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
| 866 | - wp_send_json( array( |
|
| 865 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
| 866 | + wp_send_json(array( |
|
| 867 | 867 | 'success' => $cart_invoice->get_checkout_payment_url() |
| 868 | - ) ); |
|
| 868 | + )); |
|
| 869 | 869 | wp_die(); |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | // Check if user has invoice with same items waiting to be paid. |
| 873 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
| 874 | - if ( !empty( $user_invoices ) ) { |
|
| 875 | - foreach( $user_invoices as $user_invoice ) { |
|
| 873 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
| 874 | + if (!empty($user_invoices)) { |
|
| 875 | + foreach ($user_invoices as $user_invoice) { |
|
| 876 | 876 | $user_cart_details = array(); |
| 877 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
| 877 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
| 878 | 878 | $cart_details = $invoice->get_cart_details(); |
| 879 | 879 | |
| 880 | - if ( !empty( $cart_details ) ) { |
|
| 881 | - foreach ( $cart_details as $invoice_item ) { |
|
| 880 | + if (!empty($cart_details)) { |
|
| 881 | + foreach ($cart_details as $invoice_item) { |
|
| 882 | 882 | $ii_arr = array(); |
| 883 | - $ii_arr['id'] = (int)$invoice_item['id']; |
|
| 884 | - $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
|
| 883 | + $ii_arr['id'] = (int) $invoice_item['id']; |
|
| 884 | + $ii_arr['quantity'] = (int) $invoice_item['quantity']; |
|
| 885 | 885 | |
| 886 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
| 886 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
| 887 | 887 | $ii_arr['meta'] = $invoice_item['meta']; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
| 890 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
| 891 | 891 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
| 892 | 892 | } |
| 893 | 893 | |
@@ -895,17 +895,17 @@ discard block |
||
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
| 899 | - wp_send_json( array( |
|
| 898 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
| 899 | + wp_send_json(array( |
|
| 900 | 900 | 'success' => $invoice->get_checkout_payment_url() |
| 901 | - ) ); |
|
| 901 | + )); |
|
| 902 | 902 | wp_die(); |
| 903 | 903 | } |
| 904 | 904 | } |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | // Create invoice and send user to checkout |
| 908 | - if ( !empty( $cart_items ) ) { |
|
| 908 | + if (!empty($cart_items)) { |
|
| 909 | 909 | $invoice_data = array( |
| 910 | 910 | 'status' => 'wpi-pending', |
| 911 | 911 | 'created_via' => 'wpi', |
@@ -913,21 +913,21 @@ discard block |
||
| 913 | 913 | 'cart_details' => $cart_items, |
| 914 | 914 | ); |
| 915 | 915 | |
| 916 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
| 916 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
| 917 | 917 | |
| 918 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
| 919 | - wp_send_json( array( |
|
| 918 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
| 919 | + wp_send_json(array( |
|
| 920 | 920 | 'success' => $invoice->get_checkout_payment_url() |
| 921 | - ) ); |
|
| 921 | + )); |
|
| 922 | 922 | } else { |
| 923 | - wp_send_json( array( |
|
| 924 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
| 925 | - ) ); |
|
| 923 | + wp_send_json(array( |
|
| 924 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
| 925 | + )); |
|
| 926 | 926 | } |
| 927 | 927 | } else { |
| 928 | - wp_send_json( array( |
|
| 929 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
| 930 | - ) ); |
|
| 928 | + wp_send_json(array( |
|
| 929 | + 'error' => __('Items not valid.', 'invoicing') |
|
| 930 | + )); |
|
| 931 | 931 | } |
| 932 | 932 | } |
| 933 | 933 | |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
| 161 | 161 | |
| 162 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 163 | - return 'manage_options'; |
|
| 164 | - }; |
|
| 162 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 163 | + return 'manage_options'; |
|
| 164 | + }; |
|
| 165 | 165 | |
| 166 | - return $capalibilty; |
|
| 166 | + return $capalibilty; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | function wpinv_create_user( $email ) { |
| 186 | 186 | |
| 187 | 187 | // Prepare user values. |
| 188 | - $args = array( |
|
| 189 | - 'user_login' => wpinv_generate_user_name( $email ), |
|
| 190 | - 'user_pass' => wp_generate_password(), |
|
| 191 | - 'user_email' => $email, |
|
| 192 | - 'role' => 'subscriber', |
|
| 188 | + $args = array( |
|
| 189 | + 'user_login' => wpinv_generate_user_name( $email ), |
|
| 190 | + 'user_pass' => wp_generate_password(), |
|
| 191 | + 'user_email' => $email, |
|
| 192 | + 'role' => 'subscriber', |
|
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | 195 | return wp_insert_user( $args ); |
@@ -205,19 +205,19 @@ discard block |
||
| 205 | 205 | function wpinv_generate_user_name( $prefix = '' ) { |
| 206 | 206 | |
| 207 | 207 | // If prefix is an email, retrieve the part before the email. |
| 208 | - $prefix = strtok( $prefix, '@' ); |
|
| 208 | + $prefix = strtok( $prefix, '@' ); |
|
| 209 | 209 | |
| 210 | - // Trim to 4 characters max. |
|
| 211 | - $prefix = sanitize_user( substr( $prefix, 0, 4 ) ); |
|
| 210 | + // Trim to 4 characters max. |
|
| 211 | + $prefix = sanitize_user( substr( $prefix, 0, 4 ) ); |
|
| 212 | 212 | |
| 213 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 214 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 215 | - $prefix = 'paywp'; |
|
| 216 | - } |
|
| 213 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 214 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 215 | + $prefix = 'paywp'; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 219 | - if ( username_exists( $username ) ) { |
|
| 220 | - return wpinv_generate_user_name( $prefix ); |
|
| 221 | - } |
|
| 218 | + $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 219 | + if ( username_exists( $username ) ) { |
|
| 220 | + return wpinv_generate_user_name( $prefix ); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | } |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) { |
|
| 6 | - if ( empty( $user ) ) { |
|
| 5 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC') { |
|
| 6 | + if (empty($user)) { |
|
| 7 | 7 | $user = get_current_user_id(); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - if ( empty( $user ) ) { |
|
| 10 | + if (empty($user)) { |
|
| 11 | 11 | return false; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $args = apply_filters( 'wpinv_get_users_invoices_args', array( 'user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order ) ); |
|
| 14 | + $args = apply_filters('wpinv_get_users_invoices_args', array('user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order)); |
|
| 15 | 15 | |
| 16 | - return wpinv_get_invoices( $args ); |
|
| 16 | + return wpinv_get_invoices($args); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -function wpinv_dropdown_users( $args = '' ) { |
|
| 19 | +function wpinv_dropdown_users($args = '') { |
|
| 20 | 20 | $defaults = array( |
| 21 | 21 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
| 22 | 22 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | 'option_none_value' => -1 |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
| 30 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
| 31 | 31 | |
| 32 | - $r = wp_parse_args( $args, $defaults ); |
|
| 32 | + $r = wp_parse_args($args, $defaults); |
|
| 33 | 33 | |
| 34 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
| 34 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
| 35 | 35 | |
| 36 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
| 36 | + $fields = array('ID', 'user_login', 'user_email'); |
|
| 37 | 37 | |
| 38 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
| 39 | - if ( 'display_name_with_login' === $show ) { |
|
| 38 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
| 39 | + if ('display_name_with_login' === $show) { |
|
| 40 | 40 | $fields[] = 'display_name'; |
| 41 | - } else if ( 'display_name_with_email' === $show ) { |
|
| 41 | + } else if ('display_name_with_email' === $show) { |
|
| 42 | 42 | $fields[] = 'display_name'; |
| 43 | 43 | } else { |
| 44 | 44 | $fields[] = $show; |
@@ -50,99 +50,99 @@ discard block |
||
| 50 | 50 | $show_option_none = $r['show_option_none']; |
| 51 | 51 | $option_none_value = $r['option_none_value']; |
| 52 | 52 | |
| 53 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
| 53 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
| 54 | 54 | |
| 55 | - $users = get_users( $query_args ); |
|
| 55 | + $users = get_users($query_args); |
|
| 56 | 56 | |
| 57 | 57 | $output = ''; |
| 58 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
| 59 | - $name = esc_attr( $r['name'] ); |
|
| 60 | - if ( $r['multi'] && ! $r['id'] ) { |
|
| 58 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
| 59 | + $name = esc_attr($r['name']); |
|
| 60 | + if ($r['multi'] && !$r['id']) { |
|
| 61 | 61 | $id = ''; |
| 62 | 62 | } else { |
| 63 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
| 63 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
| 64 | 64 | } |
| 65 | 65 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
| 66 | 66 | |
| 67 | - if ( $show_option_all ) { |
|
| 67 | + if ($show_option_all) { |
|
| 68 | 68 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( $show_option_none ) { |
|
| 72 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
| 73 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
| 71 | + if ($show_option_none) { |
|
| 72 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
| 73 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
| 76 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
| 77 | 77 | $found_selected = false; |
| 78 | 78 | $r['selected'] = (int) $r['selected']; |
| 79 | - foreach ( (array) $users as $user ) { |
|
| 79 | + foreach ((array) $users as $user) { |
|
| 80 | 80 | $user->ID = (int) $user->ID; |
| 81 | - if ( $user->ID === $r['selected'] ) { |
|
| 81 | + if ($user->ID === $r['selected']) { |
|
| 82 | 82 | $found_selected = true; |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( ! $found_selected ) { |
|
| 87 | - $users[] = get_userdata( $r['selected'] ); |
|
| 86 | + if (!$found_selected) { |
|
| 87 | + $users[] = get_userdata($r['selected']); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - foreach ( (array) $users as $user ) { |
|
| 92 | - if ( 'display_name_with_login' === $show ) { |
|
| 91 | + foreach ((array) $users as $user) { |
|
| 92 | + if ('display_name_with_login' === $show) { |
|
| 93 | 93 | /* translators: 1: display name, 2: user_login */ |
| 94 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
| 95 | - } elseif ( 'display_name_with_email' === $show ) { |
|
| 94 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
| 95 | + } elseif ('display_name_with_email' === $show) { |
|
| 96 | 96 | /* translators: 1: display name, 2: user_email */ |
| 97 | - if ( $user->display_name == $user->user_email ) { |
|
| 97 | + if ($user->display_name == $user->user_email) { |
|
| 98 | 98 | $display = $user->display_name; |
| 99 | 99 | } else { |
| 100 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
| 100 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
| 101 | 101 | } |
| 102 | - } elseif ( ! empty( $user->$show ) ) { |
|
| 102 | + } elseif (!empty($user->$show)) { |
|
| 103 | 103 | $display = $user->$show; |
| 104 | 104 | } else { |
| 105 | 105 | $display = '(' . $user->user_login . ')'; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
| 109 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
| 108 | + $_selected = selected($user->ID, $r['selected'], false); |
|
| 109 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $output .= "</select>"; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
| 115 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
| 116 | 116 | |
| 117 | - if ( $r['echo'] ) { |
|
| 117 | + if ($r['echo']) { |
|
| 118 | 118 | echo $html; |
| 119 | 119 | } |
| 120 | 120 | return $html; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
| 124 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
| 125 | - wpinv_login_user( $user_id ); |
|
| 123 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
| 124 | + if ((int) wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
| 125 | + wpinv_login_user($user_id); |
|
| 126 | 126 | } else { |
| 127 | - $redirect_to = wp_login_url( $redirect_to ); |
|
| 127 | + $redirect_to = wp_login_url($redirect_to); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
| 130 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
| 131 | 131 | |
| 132 | - wp_redirect( $redirect_to ); |
|
| 132 | + wp_redirect($redirect_to); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -function wpinv_login_user( $user_id ) { |
|
| 136 | - if ( is_user_logged_in() ) { |
|
| 135 | +function wpinv_login_user($user_id) { |
|
| 136 | + if (is_user_logged_in()) { |
|
| 137 | 137 | return true; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $user = get_user_by( 'id', $user_id ); |
|
| 140 | + $user = get_user_by('id', $user_id); |
|
| 141 | 141 | |
| 142 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
| 143 | - wp_set_current_user( $user_id, $user->user_login ); |
|
| 144 | - wp_set_auth_cookie( $user_id ); |
|
| 145 | - do_action( 'wp_login', $user->user_login ); |
|
| 142 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
| 143 | + wp_set_current_user($user_id, $user->user_login); |
|
| 144 | + wp_set_auth_cookie($user_id); |
|
| 145 | + do_action('wp_login', $user->user_login); |
|
| 146 | 146 | |
| 147 | 147 | return true; |
| 148 | 148 | } |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | * @return string capability to check against |
| 158 | 158 | * @param string $capalibilty Optional. The alternative capability to check against. |
| 159 | 159 | */ |
| 160 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
| 160 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
| 161 | 161 | |
| 162 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 162 | + if (current_user_can('manage_options')) { |
|
| 163 | 163 | return 'manage_options'; |
| 164 | 164 | }; |
| 165 | 165 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return bool |
| 174 | 174 | */ |
| 175 | 175 | function wpinv_current_user_can_manage_invoicing() { |
| 176 | - return current_user_can( wpinv_get_capability() ); |
|
| 176 | + return current_user_can(wpinv_get_capability()); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -182,17 +182,17 @@ discard block |
||
| 182 | 182 | * @since 1.0.19 |
| 183 | 183 | * @return int|WP_Error |
| 184 | 184 | */ |
| 185 | -function wpinv_create_user( $email ) { |
|
| 185 | +function wpinv_create_user($email) { |
|
| 186 | 186 | |
| 187 | 187 | // Prepare user values. |
| 188 | 188 | $args = array( |
| 189 | - 'user_login' => wpinv_generate_user_name( $email ), |
|
| 189 | + 'user_login' => wpinv_generate_user_name($email), |
|
| 190 | 190 | 'user_pass' => wp_generate_password(), |
| 191 | 191 | 'user_email' => $email, |
| 192 | 192 | 'role' => 'subscriber', |
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | - return wp_insert_user( $args ); |
|
| 195 | + return wp_insert_user($args); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,22 +202,22 @@ discard block |
||
| 202 | 202 | * @since 1.0.19 |
| 203 | 203 | * @return bool|WP_User |
| 204 | 204 | */ |
| 205 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
| 205 | +function wpinv_generate_user_name($prefix = '') { |
|
| 206 | 206 | |
| 207 | 207 | // If prefix is an email, retrieve the part before the email. |
| 208 | - $prefix = strtok( $prefix, '@' ); |
|
| 208 | + $prefix = strtok($prefix, '@'); |
|
| 209 | 209 | |
| 210 | 210 | // Trim to 4 characters max. |
| 211 | - $prefix = sanitize_user( substr( $prefix, 0, 4 ) ); |
|
| 211 | + $prefix = sanitize_user(substr($prefix, 0, 4)); |
|
| 212 | 212 | |
| 213 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 214 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 213 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
| 214 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
| 215 | 215 | $prefix = 'paywp'; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 219 | - if ( username_exists( $username ) ) { |
|
| 220 | - return wpinv_generate_user_name( $prefix ); |
|
| 218 | + $username = $prefix . '_' . zeroise(wp_rand(0, 9999), 4); |
|
| 219 | + if (username_exists($username)) { |
|
| 220 | + return wpinv_generate_user_name($prefix); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -13,19 +13,19 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function __construct() { |
| 15 | 15 | |
| 16 | - foreach( $this->get_elements() as $element ) { |
|
| 16 | + foreach ($this->get_elements() as $element) { |
|
| 17 | 17 | $element = $element['type']; |
| 18 | 18 | |
| 19 | - if ( method_exists( $this, "render_{$element}_template" ) ) { |
|
| 20 | - add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 ); |
|
| 19 | + if (method_exists($this, "render_{$element}_template")) { |
|
| 20 | + add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if ( method_exists( $this, "edit_{$element}_template" ) ) { |
|
| 24 | - add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 ); |
|
| 23 | + if (method_exists($this, "edit_{$element}_template")) { |
|
| 24 | + add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( method_exists( $this, "frontend_render_{$element}_template" ) ) { |
|
| 28 | - add_action( "wpinv_frontend_render_payment_form_$element", array( $this, "frontend_render_{$element}_template" ), 10, 3 ); |
|
| 27 | + if (method_exists($this, "frontend_render_{$element}_template")) { |
|
| 28 | + add_action("wpinv_frontend_render_payment_form_$element", array($this, "frontend_render_{$element}_template"), 10, 3); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function get_elements() { |
| 39 | 39 | |
| 40 | - if ( ! empty( $this->elements ) ) { |
|
| 40 | + if (!empty($this->elements)) { |
|
| 41 | 41 | return $this->elements; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,28 +45,28 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | array( |
| 47 | 47 | 'type' => 'heading', |
| 48 | - 'name' => __( 'Heading', 'invoicing' ), |
|
| 48 | + 'name' => __('Heading', 'invoicing'), |
|
| 49 | 49 | 'defaults' => array( |
| 50 | 50 | 'level' => 'h2', |
| 51 | - 'text' => __( 'Heading', 'invoicing' ), |
|
| 51 | + 'text' => __('Heading', 'invoicing'), |
|
| 52 | 52 | ) |
| 53 | 53 | ), |
| 54 | 54 | |
| 55 | 55 | array( |
| 56 | 56 | 'type' => 'paragraph', |
| 57 | - 'name' => __( 'Paragraph', 'invoicing' ), |
|
| 57 | + 'name' => __('Paragraph', 'invoicing'), |
|
| 58 | 58 | 'defaults' => array( |
| 59 | - 'text' => __( 'Paragraph text', 'invoicing' ), |
|
| 59 | + 'text' => __('Paragraph text', 'invoicing'), |
|
| 60 | 60 | ) |
| 61 | 61 | ), |
| 62 | 62 | |
| 63 | 63 | array( |
| 64 | 64 | 'type' => 'alert', |
| 65 | - 'name' => __( 'Alert', 'invoicing' ), |
|
| 65 | + 'name' => __('Alert', 'invoicing'), |
|
| 66 | 66 | 'defaults' => array( |
| 67 | 67 | 'value' => '', |
| 68 | 68 | 'class' => 'alert-warning', |
| 69 | - 'text' => __( 'Alert', 'invoicing' ), |
|
| 69 | + 'text' => __('Alert', 'invoicing'), |
|
| 70 | 70 | 'dismissible' => false, |
| 71 | 71 | ) |
| 72 | 72 | ), |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | array( |
| 84 | 84 | 'type' => 'text', |
| 85 | - 'name' => __( 'Text Input', 'invoicing' ), |
|
| 85 | + 'name' => __('Text Input', 'invoicing'), |
|
| 86 | 86 | 'defaults' => array( |
| 87 | - 'placeholder' => __( 'Enter some text', 'invoicing' ), |
|
| 87 | + 'placeholder' => __('Enter some text', 'invoicing'), |
|
| 88 | 88 | 'value' => '', |
| 89 | - 'label' => __( 'Field Label', 'invoicing' ), |
|
| 89 | + 'label' => __('Field Label', 'invoicing'), |
|
| 90 | 90 | 'description' => '', |
| 91 | 91 | 'required' => false, |
| 92 | 92 | ) |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | array( |
| 96 | 96 | 'type' => 'textarea', |
| 97 | - 'name' => __( 'Textarea', 'invoicing' ), |
|
| 97 | + 'name' => __('Textarea', 'invoicing'), |
|
| 98 | 98 | 'defaults' => array( |
| 99 | - 'placeholder' => __( 'Enter your text hear', 'invoicing' ), |
|
| 99 | + 'placeholder' => __('Enter your text hear', 'invoicing'), |
|
| 100 | 100 | 'value' => '', |
| 101 | - 'label' => __( 'Textarea Label', 'invoicing' ), |
|
| 101 | + 'label' => __('Textarea Label', 'invoicing'), |
|
| 102 | 102 | 'description' => '', |
| 103 | 103 | 'required' => false, |
| 104 | 104 | ) |
@@ -106,27 +106,27 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | array( |
| 108 | 108 | 'type' => 'select', |
| 109 | - 'name' => __( 'Dropdown', 'invoicing' ), |
|
| 109 | + 'name' => __('Dropdown', 'invoicing'), |
|
| 110 | 110 | 'defaults' => array( |
| 111 | - 'placeholder' => __( 'Select a value', 'invoicing' ), |
|
| 111 | + 'placeholder' => __('Select a value', 'invoicing'), |
|
| 112 | 112 | 'value' => '', |
| 113 | - 'label' => __( 'Dropdown Label', 'invoicing' ), |
|
| 113 | + 'label' => __('Dropdown Label', 'invoicing'), |
|
| 114 | 114 | 'description' => '', |
| 115 | 115 | 'required' => false, |
| 116 | 116 | 'options' => array( |
| 117 | - esc_attr__( 'Option One', 'invoicing' ), |
|
| 118 | - esc_attr__( 'Option Two', 'invoicing' ), |
|
| 119 | - esc_attr__( 'Option Three', 'invoicing' ) |
|
| 117 | + esc_attr__('Option One', 'invoicing'), |
|
| 118 | + esc_attr__('Option Two', 'invoicing'), |
|
| 119 | + esc_attr__('Option Three', 'invoicing') |
|
| 120 | 120 | ), |
| 121 | 121 | ) |
| 122 | 122 | ), |
| 123 | 123 | |
| 124 | 124 | array( |
| 125 | 125 | 'type' => 'checkbox', |
| 126 | - 'name' => __( 'Checkbox', 'invoicing' ), |
|
| 126 | + 'name' => __('Checkbox', 'invoicing'), |
|
| 127 | 127 | 'defaults' => array( |
| 128 | 128 | 'value' => '', |
| 129 | - 'label' => __( 'Checkbox Label', 'invoicing' ), |
|
| 129 | + 'label' => __('Checkbox Label', 'invoicing'), |
|
| 130 | 130 | 'description' => '', |
| 131 | 131 | 'required' => false, |
| 132 | 132 | ) |
@@ -134,24 +134,24 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | array( |
| 136 | 136 | 'type' => 'radio', |
| 137 | - 'name' => __( 'Multiple Choice', 'invoicing' ), |
|
| 137 | + 'name' => __('Multiple Choice', 'invoicing'), |
|
| 138 | 138 | 'defaults' => array( |
| 139 | - 'label' => __( 'Select one choice', 'invoicing' ), |
|
| 139 | + 'label' => __('Select one choice', 'invoicing'), |
|
| 140 | 140 | 'options' => array( |
| 141 | - esc_attr__( 'Choice One', 'invoicing' ), |
|
| 142 | - esc_attr__( 'Choice Two', 'invoicing' ), |
|
| 143 | - esc_attr__( 'Choice Three', 'invoicing' ) |
|
| 141 | + esc_attr__('Choice One', 'invoicing'), |
|
| 142 | + esc_attr__('Choice Two', 'invoicing'), |
|
| 143 | + esc_attr__('Choice Three', 'invoicing') |
|
| 144 | 144 | ), |
| 145 | 145 | ) |
| 146 | 146 | ), |
| 147 | 147 | |
| 148 | 148 | array( |
| 149 | 149 | 'type' => 'date', |
| 150 | - 'name' => __( 'Date', 'invoicing' ), |
|
| 150 | + 'name' => __('Date', 'invoicing'), |
|
| 151 | 151 | 'defaults' => array( |
| 152 | 152 | 'placeholder' => '', |
| 153 | 153 | 'value' => '', |
| 154 | - 'label' => __( 'Date', 'invoicing' ), |
|
| 154 | + 'label' => __('Date', 'invoicing'), |
|
| 155 | 155 | 'description' => '', |
| 156 | 156 | 'required' => false, |
| 157 | 157 | ) |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | array( |
| 161 | 161 | 'type' => 'time', |
| 162 | - 'name' => __( 'Time', 'invoicing' ), |
|
| 162 | + 'name' => __('Time', 'invoicing'), |
|
| 163 | 163 | 'defaults' => array( |
| 164 | 164 | 'placeholder' => '', |
| 165 | 165 | 'value' => '', |
| 166 | - 'label' => __( 'Time', 'invoicing' ), |
|
| 166 | + 'label' => __('Time', 'invoicing'), |
|
| 167 | 167 | 'description' => '', |
| 168 | 168 | 'required' => false, |
| 169 | 169 | ) |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | array( |
| 173 | 173 | 'type' => 'number', |
| 174 | - 'name' => __( 'Number', 'invoicing' ), |
|
| 174 | + 'name' => __('Number', 'invoicing'), |
|
| 175 | 175 | 'defaults' => array( |
| 176 | 176 | 'placeholder' => '', |
| 177 | 177 | 'value' => '', |
| 178 | - 'label' => __( 'Number', 'invoicing' ), |
|
| 178 | + 'label' => __('Number', 'invoicing'), |
|
| 179 | 179 | 'description' => '', |
| 180 | 180 | 'required' => false, |
| 181 | 181 | ) |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | array( |
| 185 | 185 | 'type' => 'website', |
| 186 | - 'name' => __( 'Website', 'invoicing' ), |
|
| 186 | + 'name' => __('Website', 'invoicing'), |
|
| 187 | 187 | 'defaults' => array( |
| 188 | 188 | 'placeholder' => 'http://example.com', |
| 189 | 189 | 'value' => '', |
| 190 | - 'label' => __( 'Website', 'invoicing' ), |
|
| 190 | + 'label' => __('Website', 'invoicing'), |
|
| 191 | 191 | 'description' => '', |
| 192 | 192 | 'required' => false, |
| 193 | 193 | ) |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | array( |
| 197 | 197 | 'type' => 'email', |
| 198 | - 'name' => __( 'Email', 'invoicing' ), |
|
| 198 | + 'name' => __('Email', 'invoicing'), |
|
| 199 | 199 | 'defaults' => array( |
| 200 | 200 | 'placeholder' => '[email protected]', |
| 201 | 201 | 'value' => '', |
| 202 | - 'label' => __( 'Email Address', 'invoicing' ), |
|
| 202 | + 'label' => __('Email Address', 'invoicing'), |
|
| 203 | 203 | 'description' => '', |
| 204 | 204 | 'required' => false, |
| 205 | 205 | ) |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | array( |
| 209 | 209 | 'type' => 'billing_email', |
| 210 | - 'name' => __( 'Billing Email', 'invoicing' ), |
|
| 210 | + 'name' => __('Billing Email', 'invoicing'), |
|
| 211 | 211 | 'defaults' => array( |
| 212 | 212 | 'placeholder' => '[email protected]', |
| 213 | 213 | 'value' => '', |
| 214 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
| 214 | + 'label' => __('Billing Email', 'invoicing'), |
|
| 215 | 215 | 'description' => '', |
| 216 | 216 | 'premade' => true, |
| 217 | 217 | ) |
@@ -219,18 +219,18 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | array( |
| 221 | 221 | 'type' => 'discount', |
| 222 | - 'name' => __( 'Discount Input', 'invoicing' ), |
|
| 222 | + 'name' => __('Discount Input', 'invoicing'), |
|
| 223 | 223 | 'defaults' => array( |
| 224 | 224 | 'value' => '', |
| 225 | - 'input_label' => __( 'Coupon Code', 'invoicing' ), |
|
| 226 | - 'button_label' => __( 'Apply Coupon', 'invoicing' ), |
|
| 227 | - 'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
|
| 225 | + 'input_label' => __('Coupon Code', 'invoicing'), |
|
| 226 | + 'button_label' => __('Apply Coupon', 'invoicing'), |
|
| 227 | + 'description' => __('Have a discount code? Enter it above.', 'invoicing'), |
|
| 228 | 228 | ) |
| 229 | 229 | ), |
| 230 | 230 | |
| 231 | 231 | array( |
| 232 | 232 | 'type' => 'items', |
| 233 | - 'name' => __( 'Items', 'invoicing' ), |
|
| 233 | + 'name' => __('Items', 'invoicing'), |
|
| 234 | 234 | 'defaults' => array( |
| 235 | 235 | 'value' => '', |
| 236 | 236 | 'items_type' => 'total', |
@@ -241,25 +241,25 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | array( |
| 243 | 243 | 'type' => 'pay_button', |
| 244 | - 'name' => __( 'Payment Button', 'invoicing' ), |
|
| 244 | + 'name' => __('Payment Button', 'invoicing'), |
|
| 245 | 245 | 'defaults' => array( |
| 246 | 246 | 'value' => '', |
| 247 | 247 | 'class' => 'btn-primary', |
| 248 | - 'label' => __( 'Pay Now »', 'invoicing' ), |
|
| 249 | - 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
| 248 | + 'label' => __('Pay Now »', 'invoicing'), |
|
| 249 | + 'description' => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
| 250 | 250 | 'premade' => true, |
| 251 | 251 | ) |
| 252 | 252 | ) |
| 253 | 253 | ); |
| 254 | 254 | |
| 255 | - $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements ); |
|
| 255 | + $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements); |
|
| 256 | 256 | return $this->elements; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * Returns the restrict markup. |
| 261 | 261 | */ |
| 262 | - public function get_restrict_markup( $field, $field_type ) { |
|
| 262 | + public function get_restrict_markup($field, $field_type) { |
|
| 263 | 263 | $restrict = "$field.type=='$field_type'"; |
| 264 | 264 | return "v-if=\"$restrict\""; |
| 265 | 265 | } |
@@ -267,15 +267,15 @@ discard block |
||
| 267 | 267 | /** |
| 268 | 268 | * Renders the title element template. |
| 269 | 269 | */ |
| 270 | - public function render_heading_template( $field ) { |
|
| 271 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
| 270 | + public function render_heading_template($field) { |
|
| 271 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
| 272 | 272 | echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * Renders the title element on the frontend. |
| 277 | 277 | */ |
| 278 | - public function frontend_render_heading_template( $field ) { |
|
| 278 | + public function frontend_render_heading_template($field) { |
|
| 279 | 279 | $tag = $field['level']; |
| 280 | 280 | echo "<$tag>{$field['text']}</$tag>"; |
| 281 | 281 | } |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | /** |
| 284 | 284 | * Renders the edit title element template. |
| 285 | 285 | */ |
| 286 | - public function edit_heading_template( $field ) { |
|
| 287 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
| 288 | - $label = __( 'Heading', 'invoicing' ); |
|
| 289 | - $label2 = __( 'Select Heading Level', 'invoicing' ); |
|
| 286 | + public function edit_heading_template($field) { |
|
| 287 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
| 288 | + $label = __('Heading', 'invoicing'); |
|
| 289 | + $label2 = __('Select Heading Level', 'invoicing'); |
|
| 290 | 290 | $id = $field . '.id + "_edit"'; |
| 291 | 291 | $id2 = $field . '.id + "_edit2"'; |
| 292 | 292 | |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | /** |
| 319 | 319 | * Renders a paragraph element template. |
| 320 | 320 | */ |
| 321 | - public function render_paragraph_template( $field ) { |
|
| 322 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
| 321 | + public function render_paragraph_template($field) { |
|
| 322 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
| 323 | 323 | $label = "$field.text"; |
| 324 | 324 | echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
| 325 | 325 | } |
@@ -327,16 +327,16 @@ discard block |
||
| 327 | 327 | /** |
| 328 | 328 | * Renders the paragraph element on the frontend. |
| 329 | 329 | */ |
| 330 | - public function frontend_render_paragraph_template( $field ) { |
|
| 330 | + public function frontend_render_paragraph_template($field) { |
|
| 331 | 331 | echo "<p>{$field['text']}</p>"; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | 335 | * Renders the edit paragraph element template. |
| 336 | 336 | */ |
| 337 | - public function edit_paragraph_template( $field ) { |
|
| 338 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
| 339 | - $label = __( 'Enter your text', 'invoicing' ); |
|
| 337 | + public function edit_paragraph_template($field) { |
|
| 338 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
| 339 | + $label = __('Enter your text', 'invoicing'); |
|
| 340 | 340 | $id = $field . '.id + "_edit"'; |
| 341 | 341 | echo " |
| 342 | 342 | <div $restrict> |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | /** |
| 353 | 353 | * Renders the text element template. |
| 354 | 354 | */ |
| 355 | - public function render_text_template( $field ) { |
|
| 356 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
| 355 | + public function render_text_template($field) { |
|
| 356 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
| 357 | 357 | $label = "$field.label"; |
| 358 | 358 | echo " |
| 359 | 359 | <div $restrict> |
@@ -367,23 +367,23 @@ discard block |
||
| 367 | 367 | /** |
| 368 | 368 | * Renders the text element on the frontend. |
| 369 | 369 | */ |
| 370 | - public function frontend_render_text_template( $field ) { |
|
| 370 | + public function frontend_render_text_template($field) { |
|
| 371 | 371 | |
| 372 | 372 | echo "<div class='form-group'>"; |
| 373 | 373 | |
| 374 | 374 | echo aui()->input( |
| 375 | 375 | array( |
| 376 | - 'name' => esc_attr( $field['id'] ), |
|
| 377 | - 'id' => esc_attr( $field['id'] ), |
|
| 378 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
| 376 | + 'name' => esc_attr($field['id']), |
|
| 377 | + 'id' => esc_attr($field['id']), |
|
| 378 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
| 379 | 379 | 'required' => (bool) $field['required'], |
| 380 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 380 | + 'label' => wp_kses_post($field['label']), |
|
| 381 | 381 | 'no_wrap' => true, |
| 382 | 382 | ) |
| 383 | 383 | ); |
| 384 | 384 | |
| 385 | - if ( ! empty( $field['description'] ) ) { |
|
| 386 | - $description = wp_kses_post( $field['description'] ); |
|
| 385 | + if (!empty($field['description'])) { |
|
| 386 | + $description = wp_kses_post($field['description']); |
|
| 387 | 387 | echo "<small class='form-text text-muted'>$description</small>"; |
| 388 | 388 | } |
| 389 | 389 | |
@@ -394,16 +394,16 @@ discard block |
||
| 394 | 394 | /** |
| 395 | 395 | * Renders the edit text element template. |
| 396 | 396 | */ |
| 397 | - public function edit_text_template( $field ) { |
|
| 398 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
| 399 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 397 | + public function edit_text_template($field) { |
|
| 398 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
| 399 | + $label = __('Field Label', 'invoicing'); |
|
| 400 | 400 | $id = $field . '.id + "_edit"'; |
| 401 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 401 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 402 | 402 | $id2 = $field . '.id + "_edit2"'; |
| 403 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 404 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 403 | + $label3 = __('Help text', 'invoicing'); |
|
| 404 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 405 | 405 | $id3 = $field . '.id + "_edit3"'; |
| 406 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 406 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 407 | 407 | $id4 = $field . '.id + "_edit4"'; |
| 408 | 408 | echo " |
| 409 | 409 | <div $restrict> |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | /** |
| 432 | 432 | * Renders the textarea element template. |
| 433 | 433 | */ |
| 434 | - public function render_textarea_template( $field ) { |
|
| 435 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
| 434 | + public function render_textarea_template($field) { |
|
| 435 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
| 436 | 436 | $label = "$field.label"; |
| 437 | 437 | echo " |
| 438 | 438 | <div $restrict> |
@@ -446,24 +446,24 @@ discard block |
||
| 446 | 446 | /** |
| 447 | 447 | * Renders the textarea element on the frontend. |
| 448 | 448 | */ |
| 449 | - public function frontend_render_textarea_template( $field ) { |
|
| 449 | + public function frontend_render_textarea_template($field) { |
|
| 450 | 450 | |
| 451 | 451 | echo "<div class='form-group'>"; |
| 452 | 452 | |
| 453 | 453 | echo aui()->textarea( |
| 454 | 454 | array( |
| 455 | - 'name' => esc_attr( $field['id'] ), |
|
| 456 | - 'id' => esc_attr( $field['id'] ), |
|
| 457 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
| 455 | + 'name' => esc_attr($field['id']), |
|
| 456 | + 'id' => esc_attr($field['id']), |
|
| 457 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
| 458 | 458 | 'required' => (bool) $field['required'], |
| 459 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 459 | + 'label' => wp_kses_post($field['label']), |
|
| 460 | 460 | 'no_wrap' => true, |
| 461 | 461 | 'rows' => 3, |
| 462 | 462 | ) |
| 463 | 463 | ); |
| 464 | 464 | |
| 465 | - if ( ! empty( $field['description'] ) ) { |
|
| 466 | - $description = wp_kses_post( $field['description'] ); |
|
| 465 | + if (!empty($field['description'])) { |
|
| 466 | + $description = wp_kses_post($field['description']); |
|
| 467 | 467 | echo "<small class='form-text text-muted'>$description</small>"; |
| 468 | 468 | } |
| 469 | 469 | |
@@ -474,16 +474,16 @@ discard block |
||
| 474 | 474 | /** |
| 475 | 475 | * Renders the edit textarea element template. |
| 476 | 476 | */ |
| 477 | - public function edit_textarea_template( $field ) { |
|
| 478 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
| 479 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 477 | + public function edit_textarea_template($field) { |
|
| 478 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
| 479 | + $label = __('Field Label', 'invoicing'); |
|
| 480 | 480 | $id = $field . '.id + "_edit"'; |
| 481 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 481 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 482 | 482 | $id2 = $field . '.id + "_edit2"'; |
| 483 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 484 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 483 | + $label3 = __('Help text', 'invoicing'); |
|
| 484 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 485 | 485 | $id3 = $field . '.id + "_edit3"'; |
| 486 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 486 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 487 | 487 | $id4 = $field . '.id + "_edit4"'; |
| 488 | 488 | echo " |
| 489 | 489 | <div $restrict> |
@@ -511,8 +511,8 @@ discard block |
||
| 511 | 511 | /** |
| 512 | 512 | * Renders the select element template. |
| 513 | 513 | */ |
| 514 | - public function render_select_template( $field ) { |
|
| 515 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
| 514 | + public function render_select_template($field) { |
|
| 515 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
| 516 | 516 | $label = "$field.label"; |
| 517 | 517 | $placeholder = "$field.placeholder"; |
| 518 | 518 | $id = $field . '.id'; |
@@ -531,24 +531,24 @@ discard block |
||
| 531 | 531 | /** |
| 532 | 532 | * Renders the select element on the frontend. |
| 533 | 533 | */ |
| 534 | - public function frontend_render_select_template( $field ) { |
|
| 534 | + public function frontend_render_select_template($field) { |
|
| 535 | 535 | |
| 536 | 536 | echo "<div class='form-group'>"; |
| 537 | 537 | |
| 538 | 538 | echo aui()->select( |
| 539 | 539 | array( |
| 540 | - 'name' => esc_attr( $field['id'] ), |
|
| 541 | - 'id' => esc_attr( $field['id'] ), |
|
| 542 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
| 540 | + 'name' => esc_attr($field['id']), |
|
| 541 | + 'id' => esc_attr($field['id']), |
|
| 542 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
| 543 | 543 | 'required' => (bool) $field['required'], |
| 544 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 544 | + 'label' => wp_kses_post($field['label']), |
|
| 545 | 545 | 'no_wrap' => true, |
| 546 | 546 | 'options' => $field['options'], |
| 547 | 547 | ) |
| 548 | 548 | ); |
| 549 | 549 | |
| 550 | - if ( ! empty( $field['description'] ) ) { |
|
| 551 | - $description = wp_kses_post( $field['description'] ); |
|
| 550 | + if (!empty($field['description'])) { |
|
| 551 | + $description = wp_kses_post($field['description']); |
|
| 552 | 552 | echo "<small class='form-text text-muted'>$description</small>"; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -559,18 +559,18 @@ discard block |
||
| 559 | 559 | /** |
| 560 | 560 | * Renders the edit select element template. |
| 561 | 561 | */ |
| 562 | - public function edit_select_template( $field ) { |
|
| 563 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
| 564 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 562 | + public function edit_select_template($field) { |
|
| 563 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
| 564 | + $label = __('Field Label', 'invoicing'); |
|
| 565 | 565 | $id = $field . '.id + "_edit"'; |
| 566 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 566 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 567 | 567 | $id2 = $field . '.id + "_edit2"'; |
| 568 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 569 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 568 | + $label3 = __('Help text', 'invoicing'); |
|
| 569 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 570 | 570 | $id3 = $field . '.id + "_edit3"'; |
| 571 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 571 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 572 | 572 | $id4 = $field . '.id + "_edit4"'; |
| 573 | - $label6 = __( 'Available Options', 'invoicing' ); |
|
| 573 | + $label6 = __('Available Options', 'invoicing'); |
|
| 574 | 574 | echo " |
| 575 | 575 | <div $restrict> |
| 576 | 576 | <div class='form-group'> |
@@ -608,8 +608,8 @@ discard block |
||
| 608 | 608 | /** |
| 609 | 609 | * Renders the checkbox element template. |
| 610 | 610 | */ |
| 611 | - public function render_checkbox_template( $field ) { |
|
| 612 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
| 611 | + public function render_checkbox_template($field) { |
|
| 612 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
| 613 | 613 | $label = "$field.label"; |
| 614 | 614 | echo " |
| 615 | 615 | <div class='form-check' $restrict> |
@@ -623,23 +623,23 @@ discard block |
||
| 623 | 623 | /** |
| 624 | 624 | * Renders the checkbox element on the frontend. |
| 625 | 625 | */ |
| 626 | - public function frontend_render_checkbox_template( $field ) { |
|
| 626 | + public function frontend_render_checkbox_template($field) { |
|
| 627 | 627 | |
| 628 | 628 | echo "<div class='form-group'>"; |
| 629 | 629 | |
| 630 | 630 | echo aui()->input( |
| 631 | 631 | array( |
| 632 | - 'name' => esc_attr( $field['id'] ), |
|
| 633 | - 'id' => esc_attr( $field['id'] ), |
|
| 632 | + 'name' => esc_attr($field['id']), |
|
| 633 | + 'id' => esc_attr($field['id']), |
|
| 634 | 634 | 'required' => (bool) $field['required'], |
| 635 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 635 | + 'label' => wp_kses_post($field['label']), |
|
| 636 | 636 | 'no_wrap' => true, |
| 637 | 637 | 'type' => 'checkbox', |
| 638 | 638 | ) |
| 639 | 639 | ); |
| 640 | 640 | |
| 641 | - if ( ! empty( $field['description'] ) ) { |
|
| 642 | - $description = wp_kses_post( $field['description'] ); |
|
| 641 | + if (!empty($field['description'])) { |
|
| 642 | + $description = wp_kses_post($field['description']); |
|
| 643 | 643 | echo "<small class='form-text text-muted'>$description</small>"; |
| 644 | 644 | } |
| 645 | 645 | |
@@ -650,14 +650,14 @@ discard block |
||
| 650 | 650 | /** |
| 651 | 651 | * Renders the edit checkbox element template. |
| 652 | 652 | */ |
| 653 | - public function edit_checkbox_template( $field ) { |
|
| 654 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
| 655 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 653 | + public function edit_checkbox_template($field) { |
|
| 654 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
| 655 | + $label = __('Field Label', 'invoicing'); |
|
| 656 | 656 | $id = $field . '.id + "_edit"'; |
| 657 | - $label2 = __( 'Help text', 'invoicing' ); |
|
| 658 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 657 | + $label2 = __('Help text', 'invoicing'); |
|
| 658 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 659 | 659 | $id2 = $field . '.id + "_edit2"'; |
| 660 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
| 660 | + $label4 = __('Is this field required?', 'invoicing'); |
|
| 661 | 661 | $id3 = $field . '.id + "_edit3"'; |
| 662 | 662 | echo " |
| 663 | 663 | <div $restrict> |
@@ -681,8 +681,8 @@ discard block |
||
| 681 | 681 | /** |
| 682 | 682 | * Renders the radio element template. |
| 683 | 683 | */ |
| 684 | - public function render_radio_template( $field ) { |
|
| 685 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
| 684 | + public function render_radio_template($field) { |
|
| 685 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
| 686 | 686 | $label = "$field.label"; |
| 687 | 687 | $id = $field . '.id'; |
| 688 | 688 | echo " |
@@ -700,19 +700,19 @@ discard block |
||
| 700 | 700 | /** |
| 701 | 701 | * Renders the radio element on the frontend. |
| 702 | 702 | */ |
| 703 | - public function frontend_render_radio_template( $field ) { |
|
| 703 | + public function frontend_render_radio_template($field) { |
|
| 704 | 704 | |
| 705 | 705 | echo "<div class='form-group'>"; |
| 706 | 706 | |
| 707 | - if ( ! empty( $field['label'] ) ) { |
|
| 708 | - $label = wp_kses_post( $field['label'] ); |
|
| 707 | + if (!empty($field['label'])) { |
|
| 708 | + $label = wp_kses_post($field['label']); |
|
| 709 | 709 | echo "<legend class='col-form-label'>$label</legend>"; |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - foreach( $field['options'] as $index => $option ) { |
|
| 712 | + foreach ($field['options'] as $index => $option) { |
|
| 713 | 713 | $id = $field['id'] . $index; |
| 714 | - $value = esc_attr( $option ); |
|
| 715 | - $label = wp_kses_post( $option ); |
|
| 714 | + $value = esc_attr($option); |
|
| 715 | + $label = wp_kses_post($option); |
|
| 716 | 716 | |
| 717 | 717 | echo " |
| 718 | 718 | <div class='form-check'> |
@@ -722,8 +722,8 @@ discard block |
||
| 722 | 722 | "; |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - if ( ! empty( $field['description'] ) ) { |
|
| 726 | - $description = wp_kses_post( $field['description'] ); |
|
| 725 | + if (!empty($field['description'])) { |
|
| 726 | + $description = wp_kses_post($field['description']); |
|
| 727 | 727 | echo "<small class='form-text text-muted'>$description</small>"; |
| 728 | 728 | } |
| 729 | 729 | |
@@ -734,16 +734,16 @@ discard block |
||
| 734 | 734 | /** |
| 735 | 735 | * Renders the edit radio element template. |
| 736 | 736 | */ |
| 737 | - public function edit_radio_template( $field ) { |
|
| 738 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
| 739 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 737 | + public function edit_radio_template($field) { |
|
| 738 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
| 739 | + $label = __('Field Label', 'invoicing'); |
|
| 740 | 740 | $id = $field . '.id + "_edit"'; |
| 741 | - $label2 = __( 'Help text', 'invoicing' ); |
|
| 742 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 741 | + $label2 = __('Help text', 'invoicing'); |
|
| 742 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 743 | 743 | $id2 = $field . '.id + "_edit3"'; |
| 744 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
| 744 | + $label4 = __('Is this field required?', 'invoicing'); |
|
| 745 | 745 | $id3 = $field . '.id + "_edit4"'; |
| 746 | - $label5 = __( 'Available Options', 'invoicing' ); |
|
| 746 | + $label5 = __('Available Options', 'invoicing'); |
|
| 747 | 747 | echo " |
| 748 | 748 | <div $restrict> |
| 749 | 749 | <div class='form-group'> |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | /** |
| 778 | 778 | * Renders the email element template. |
| 779 | 779 | */ |
| 780 | - public function render_email_template( $field ) { |
|
| 781 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
| 780 | + public function render_email_template($field) { |
|
| 781 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
| 782 | 782 | $label = "$field.label"; |
| 783 | 783 | echo " |
| 784 | 784 | <div $restrict> |
@@ -792,8 +792,8 @@ discard block |
||
| 792 | 792 | /** |
| 793 | 793 | * Renders the billing_email element template. |
| 794 | 794 | */ |
| 795 | - public function render_billing_email_template( $field ) { |
|
| 796 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
| 795 | + public function render_billing_email_template($field) { |
|
| 796 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
| 797 | 797 | $label = "$field.label"; |
| 798 | 798 | echo " |
| 799 | 799 | <div $restrict> |
@@ -807,24 +807,24 @@ discard block |
||
| 807 | 807 | /** |
| 808 | 808 | * Renders the email element on the frontend. |
| 809 | 809 | */ |
| 810 | - public function frontend_render_email_template( $field ) { |
|
| 810 | + public function frontend_render_email_template($field) { |
|
| 811 | 811 | |
| 812 | 812 | echo "<div class='form-group'>"; |
| 813 | 813 | |
| 814 | 814 | echo aui()->input( |
| 815 | 815 | array( |
| 816 | - 'name' => esc_attr( $field['id'] ), |
|
| 817 | - 'id' => esc_attr( $field['id'] ), |
|
| 816 | + 'name' => esc_attr($field['id']), |
|
| 817 | + 'id' => esc_attr($field['id']), |
|
| 818 | 818 | 'required' => (bool) $field['required'], |
| 819 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 819 | + 'label' => wp_kses_post($field['label']), |
|
| 820 | 820 | 'no_wrap' => true, |
| 821 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 821 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 822 | 822 | 'type' => 'email', |
| 823 | 823 | ) |
| 824 | 824 | ); |
| 825 | 825 | |
| 826 | - if ( ! empty( $field['description'] ) ) { |
|
| 827 | - $description = wp_kses_post( $field['description'] ); |
|
| 826 | + if (!empty($field['description'])) { |
|
| 827 | + $description = wp_kses_post($field['description']); |
|
| 828 | 828 | echo "<small class='form-text text-muted'>$description</small>"; |
| 829 | 829 | } |
| 830 | 830 | |
@@ -835,24 +835,24 @@ discard block |
||
| 835 | 835 | /** |
| 836 | 836 | * Renders the billing email element on the frontend. |
| 837 | 837 | */ |
| 838 | - public function frontend_render_billing_email_template( $field ) { |
|
| 838 | + public function frontend_render_billing_email_template($field) { |
|
| 839 | 839 | |
| 840 | 840 | echo "<div class='form-group'>"; |
| 841 | 841 | |
| 842 | 842 | echo aui()->input( |
| 843 | 843 | array( |
| 844 | 844 | 'name' => 'billing_email', |
| 845 | - 'id' => esc_attr( $field['id'] ), |
|
| 845 | + 'id' => esc_attr($field['id']), |
|
| 846 | 846 | 'required' => true, |
| 847 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 847 | + 'label' => wp_kses_post($field['label']), |
|
| 848 | 848 | 'no_wrap' => true, |
| 849 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 849 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 850 | 850 | 'type' => 'email', |
| 851 | 851 | ) |
| 852 | 852 | ); |
| 853 | 853 | |
| 854 | - if ( ! empty( $field['description'] ) ) { |
|
| 855 | - $description = wp_kses_post( $field['description'] ); |
|
| 854 | + if (!empty($field['description'])) { |
|
| 855 | + $description = wp_kses_post($field['description']); |
|
| 856 | 856 | echo "<small class='form-text text-muted'>$description</small>"; |
| 857 | 857 | } |
| 858 | 858 | |
@@ -863,16 +863,16 @@ discard block |
||
| 863 | 863 | /** |
| 864 | 864 | * Renders the edit email element template. |
| 865 | 865 | */ |
| 866 | - public function edit_email_template( $field ) { |
|
| 867 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
| 868 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 866 | + public function edit_email_template($field) { |
|
| 867 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
| 868 | + $label = __('Field Label', 'invoicing'); |
|
| 869 | 869 | $id = $field . '.id + "_edit"'; |
| 870 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 870 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 871 | 871 | $id2 = $field . '.id + "_edit2"'; |
| 872 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 873 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 872 | + $label3 = __('Help text', 'invoicing'); |
|
| 873 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 874 | 874 | $id3 = $field . '.id + "_edit3"'; |
| 875 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 875 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 876 | 876 | $id4 = $field . '.id + "_edit4"'; |
| 877 | 877 | echo " |
| 878 | 878 | <div $restrict> |
@@ -900,16 +900,16 @@ discard block |
||
| 900 | 900 | /** |
| 901 | 901 | * Renders the edit billing_email element template. |
| 902 | 902 | */ |
| 903 | - public function edit_billing_email_template( $field ) { |
|
| 904 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
| 905 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 903 | + public function edit_billing_email_template($field) { |
|
| 904 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
| 905 | + $label = __('Field Label', 'invoicing'); |
|
| 906 | 906 | $id = $field . '.id + "_edit"'; |
| 907 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 907 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 908 | 908 | $id2 = $field . '.id + "_edit2"'; |
| 909 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 910 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 909 | + $label3 = __('Help text', 'invoicing'); |
|
| 910 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 911 | 911 | $id3 = $field . '.id + "_edit3"'; |
| 912 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 912 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 913 | 913 | $id4 = $field . '.id + "_edit4"'; |
| 914 | 914 | echo " |
| 915 | 915 | <div $restrict> |
@@ -933,8 +933,8 @@ discard block |
||
| 933 | 933 | /** |
| 934 | 934 | * Renders the website element template. |
| 935 | 935 | */ |
| 936 | - public function render_website_template( $field ) { |
|
| 937 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
| 936 | + public function render_website_template($field) { |
|
| 937 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
| 938 | 938 | $label = "$field.label"; |
| 939 | 939 | echo " |
| 940 | 940 | <div $restrict> |
@@ -948,24 +948,24 @@ discard block |
||
| 948 | 948 | /** |
| 949 | 949 | * Renders the website element on the frontend. |
| 950 | 950 | */ |
| 951 | - public function frontend_render_website_template( $field ) { |
|
| 951 | + public function frontend_render_website_template($field) { |
|
| 952 | 952 | |
| 953 | 953 | echo "<div class='form-group'>"; |
| 954 | 954 | |
| 955 | 955 | echo aui()->input( |
| 956 | 956 | array( |
| 957 | - 'name' => esc_attr( $field['id'] ), |
|
| 958 | - 'id' => esc_attr( $field['id'] ), |
|
| 957 | + 'name' => esc_attr($field['id']), |
|
| 958 | + 'id' => esc_attr($field['id']), |
|
| 959 | 959 | 'required' => (bool) $field['required'], |
| 960 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 960 | + 'label' => wp_kses_post($field['label']), |
|
| 961 | 961 | 'no_wrap' => true, |
| 962 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 962 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 963 | 963 | 'type' => 'url', |
| 964 | 964 | ) |
| 965 | 965 | ); |
| 966 | 966 | |
| 967 | - if ( ! empty( $field['description'] ) ) { |
|
| 968 | - $description = wp_kses_post( $field['description'] ); |
|
| 967 | + if (!empty($field['description'])) { |
|
| 968 | + $description = wp_kses_post($field['description']); |
|
| 969 | 969 | echo "<small class='form-text text-muted'>$description</small>"; |
| 970 | 970 | } |
| 971 | 971 | |
@@ -976,16 +976,16 @@ discard block |
||
| 976 | 976 | /** |
| 977 | 977 | * Renders the edit website element template. |
| 978 | 978 | */ |
| 979 | - public function edit_website_template( $field ) { |
|
| 980 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
| 981 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 979 | + public function edit_website_template($field) { |
|
| 980 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
| 981 | + $label = __('Field Label', 'invoicing'); |
|
| 982 | 982 | $id = $field . '.id + "_edit"'; |
| 983 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 983 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 984 | 984 | $id2 = $field . '.id + "_edit2"'; |
| 985 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 986 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 985 | + $label3 = __('Help text', 'invoicing'); |
|
| 986 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 987 | 987 | $id3 = $field . '.id + "_edit3"'; |
| 988 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 988 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 989 | 989 | $id4 = $field . '.id + "_edit4"'; |
| 990 | 990 | echo " |
| 991 | 991 | <div $restrict> |
@@ -1013,8 +1013,8 @@ discard block |
||
| 1013 | 1013 | /** |
| 1014 | 1014 | * Renders the date element template. |
| 1015 | 1015 | */ |
| 1016 | - public function render_date_template( $field ) { |
|
| 1017 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
| 1016 | + public function render_date_template($field) { |
|
| 1017 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
| 1018 | 1018 | $label = "$field.label"; |
| 1019 | 1019 | echo " |
| 1020 | 1020 | <div $restrict> |
@@ -1028,24 +1028,24 @@ discard block |
||
| 1028 | 1028 | /** |
| 1029 | 1029 | * Renders the date element on the frontend. |
| 1030 | 1030 | */ |
| 1031 | - public function frontend_render_date_template( $field ) { |
|
| 1031 | + public function frontend_render_date_template($field) { |
|
| 1032 | 1032 | |
| 1033 | 1033 | echo "<div class='form-group'>"; |
| 1034 | 1034 | |
| 1035 | 1035 | echo aui()->input( |
| 1036 | 1036 | array( |
| 1037 | - 'name' => esc_attr( $field['id'] ), |
|
| 1038 | - 'id' => esc_attr( $field['id'] ), |
|
| 1037 | + 'name' => esc_attr($field['id']), |
|
| 1038 | + 'id' => esc_attr($field['id']), |
|
| 1039 | 1039 | 'required' => (bool) $field['required'], |
| 1040 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1041 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1040 | + 'label' => wp_kses_post($field['label']), |
|
| 1041 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1042 | 1042 | 'no_wrap' => true, |
| 1043 | 1043 | 'type' => 'date', |
| 1044 | 1044 | ) |
| 1045 | 1045 | ); |
| 1046 | 1046 | |
| 1047 | - if ( ! empty( $field['description'] ) ) { |
|
| 1048 | - $description = wp_kses_post( $field['description'] ); |
|
| 1047 | + if (!empty($field['description'])) { |
|
| 1048 | + $description = wp_kses_post($field['description']); |
|
| 1049 | 1049 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1050 | 1050 | } |
| 1051 | 1051 | |
@@ -1056,16 +1056,16 @@ discard block |
||
| 1056 | 1056 | /** |
| 1057 | 1057 | * Renders the edit date element template. |
| 1058 | 1058 | */ |
| 1059 | - public function edit_date_template( $field ) { |
|
| 1060 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
| 1061 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1059 | + public function edit_date_template($field) { |
|
| 1060 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
| 1061 | + $label = __('Field Label', 'invoicing'); |
|
| 1062 | 1062 | $id = $field . '.id + "_edit"'; |
| 1063 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1063 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1064 | 1064 | $id2 = $field . '.id + "_edit2"'; |
| 1065 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1066 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1065 | + $label3 = __('Help text', 'invoicing'); |
|
| 1066 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1067 | 1067 | $id3 = $field . '.id + "_edit3"'; |
| 1068 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1068 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1069 | 1069 | $id4 = $field . '.id + "_edit4"'; |
| 1070 | 1070 | echo " |
| 1071 | 1071 | <div $restrict> |
@@ -1093,8 +1093,8 @@ discard block |
||
| 1093 | 1093 | /** |
| 1094 | 1094 | * Renders the time element template. |
| 1095 | 1095 | */ |
| 1096 | - public function render_time_template( $field ) { |
|
| 1097 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
| 1096 | + public function render_time_template($field) { |
|
| 1097 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
| 1098 | 1098 | $label = "$field.label"; |
| 1099 | 1099 | echo " |
| 1100 | 1100 | <div $restrict> |
@@ -1108,24 +1108,24 @@ discard block |
||
| 1108 | 1108 | /** |
| 1109 | 1109 | * Renders the time element on the frontend. |
| 1110 | 1110 | */ |
| 1111 | - public function frontend_render_time_template( $field ) { |
|
| 1111 | + public function frontend_render_time_template($field) { |
|
| 1112 | 1112 | |
| 1113 | 1113 | echo "<div class='form-group'>"; |
| 1114 | 1114 | |
| 1115 | 1115 | echo aui()->input( |
| 1116 | 1116 | array( |
| 1117 | - 'name' => esc_attr( $field['id'] ), |
|
| 1118 | - 'id' => esc_attr( $field['id'] ), |
|
| 1117 | + 'name' => esc_attr($field['id']), |
|
| 1118 | + 'id' => esc_attr($field['id']), |
|
| 1119 | 1119 | 'required' => (bool) $field['required'], |
| 1120 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1120 | + 'label' => wp_kses_post($field['label']), |
|
| 1121 | 1121 | 'no_wrap' => true, |
| 1122 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1122 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1123 | 1123 | 'type' => 'time', |
| 1124 | 1124 | ) |
| 1125 | 1125 | ); |
| 1126 | 1126 | |
| 1127 | - if ( ! empty( $field['description'] ) ) { |
|
| 1128 | - $description = wp_kses_post( $field['description'] ); |
|
| 1127 | + if (!empty($field['description'])) { |
|
| 1128 | + $description = wp_kses_post($field['description']); |
|
| 1129 | 1129 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1130 | 1130 | } |
| 1131 | 1131 | |
@@ -1136,16 +1136,16 @@ discard block |
||
| 1136 | 1136 | /** |
| 1137 | 1137 | * Renders the edit time element template. |
| 1138 | 1138 | */ |
| 1139 | - public function edit_time_template( $field ) { |
|
| 1140 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
| 1141 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1139 | + public function edit_time_template($field) { |
|
| 1140 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
| 1141 | + $label = __('Field Label', 'invoicing'); |
|
| 1142 | 1142 | $id = $field . '.id + "_edit"'; |
| 1143 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1143 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1144 | 1144 | $id2 = $field . '.id + "_edit2"'; |
| 1145 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1146 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1145 | + $label3 = __('Help text', 'invoicing'); |
|
| 1146 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1147 | 1147 | $id3 = $field . '.id + "_edit3"'; |
| 1148 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1148 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1149 | 1149 | $id4 = $field . '.id + "_edit4"'; |
| 1150 | 1150 | echo " |
| 1151 | 1151 | <div $restrict> |
@@ -1173,8 +1173,8 @@ discard block |
||
| 1173 | 1173 | /** |
| 1174 | 1174 | * Renders the number element template. |
| 1175 | 1175 | */ |
| 1176 | - public function render_number_template( $field ) { |
|
| 1177 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
| 1176 | + public function render_number_template($field) { |
|
| 1177 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
| 1178 | 1178 | $label = "$field.label"; |
| 1179 | 1179 | echo " |
| 1180 | 1180 | <div $restrict> |
@@ -1188,24 +1188,24 @@ discard block |
||
| 1188 | 1188 | /** |
| 1189 | 1189 | * Renders the number element on the frontend. |
| 1190 | 1190 | */ |
| 1191 | - public function frontend_render_number_template( $field ) { |
|
| 1191 | + public function frontend_render_number_template($field) { |
|
| 1192 | 1192 | |
| 1193 | 1193 | echo "<div class='form-group'>"; |
| 1194 | 1194 | |
| 1195 | 1195 | echo aui()->input( |
| 1196 | 1196 | array( |
| 1197 | - 'name' => esc_attr( $field['id'] ), |
|
| 1198 | - 'id' => esc_attr( $field['id'] ), |
|
| 1197 | + 'name' => esc_attr($field['id']), |
|
| 1198 | + 'id' => esc_attr($field['id']), |
|
| 1199 | 1199 | 'required' => (bool) $field['required'], |
| 1200 | - 'label' => wp_kses_post( $field['label'] ), |
|
| 1201 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
| 1200 | + 'label' => wp_kses_post($field['label']), |
|
| 1201 | + 'placeholder' => esc_attr($field['placeholder']), |
|
| 1202 | 1202 | 'no_wrap' => true, |
| 1203 | 1203 | 'type' => 'number', |
| 1204 | 1204 | ) |
| 1205 | 1205 | ); |
| 1206 | 1206 | |
| 1207 | - if ( ! empty( $field['description'] ) ) { |
|
| 1208 | - $description = wp_kses_post( $field['description'] ); |
|
| 1207 | + if (!empty($field['description'])) { |
|
| 1208 | + $description = wp_kses_post($field['description']); |
|
| 1209 | 1209 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1210 | 1210 | } |
| 1211 | 1211 | |
@@ -1216,16 +1216,16 @@ discard block |
||
| 1216 | 1216 | /** |
| 1217 | 1217 | * Renders the edit number element template. |
| 1218 | 1218 | */ |
| 1219 | - public function edit_number_template( $field ) { |
|
| 1220 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
| 1221 | - $label = __( 'Field Label', 'invoicing' ); |
|
| 1219 | + public function edit_number_template($field) { |
|
| 1220 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
| 1221 | + $label = __('Field Label', 'invoicing'); |
|
| 1222 | 1222 | $id = $field . '.id + "_edit"'; |
| 1223 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
| 1223 | + $label2 = __('Placeholder text', 'invoicing'); |
|
| 1224 | 1224 | $id2 = $field . '.id + "_edit2"'; |
| 1225 | - $label3 = __( 'Help text', 'invoicing' ); |
|
| 1226 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1225 | + $label3 = __('Help text', 'invoicing'); |
|
| 1226 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1227 | 1227 | $id3 = $field . '.id + "_edit3"'; |
| 1228 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
| 1228 | + $label5 = __('Is this field required?', 'invoicing'); |
|
| 1229 | 1229 | $id4 = $field . '.id + "_edit4"'; |
| 1230 | 1230 | echo " |
| 1231 | 1231 | <div $restrict> |
@@ -1253,23 +1253,23 @@ discard block |
||
| 1253 | 1253 | /** |
| 1254 | 1254 | * Renders the separator element template. |
| 1255 | 1255 | */ |
| 1256 | - public function render_separator_template( $field ) { |
|
| 1257 | - $restrict = $this->get_restrict_markup( $field, 'separator' ); |
|
| 1256 | + public function render_separator_template($field) { |
|
| 1257 | + $restrict = $this->get_restrict_markup($field, 'separator'); |
|
| 1258 | 1258 | echo "<hr class='featurette-divider mt-0 mb-2' $restrict>"; |
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
| 1262 | 1262 | * Renders the separator element on the frontend. |
| 1263 | 1263 | */ |
| 1264 | - public function frontend_render_separator_template( $field ) { |
|
| 1264 | + public function frontend_render_separator_template($field) { |
|
| 1265 | 1265 | echo '<hr class="featurette-divider mt-0 mb-2" />'; |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | /** |
| 1269 | 1269 | * Renders the pay button element template. |
| 1270 | 1270 | */ |
| 1271 | - public function render_pay_button_template( $field ) { |
|
| 1272 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
| 1271 | + public function render_pay_button_template($field) { |
|
| 1272 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
| 1273 | 1273 | $label = "$field.label"; |
| 1274 | 1274 | echo " |
| 1275 | 1275 | <div $restrict> |
@@ -1282,24 +1282,24 @@ discard block |
||
| 1282 | 1282 | /** |
| 1283 | 1283 | * Renders the pay_button element on the frontend. |
| 1284 | 1284 | */ |
| 1285 | - public function frontend_render_pay_button_template( $field ) { |
|
| 1285 | + public function frontend_render_pay_button_template($field) { |
|
| 1286 | 1286 | |
| 1287 | 1287 | echo "<div class='form-group'>"; |
| 1288 | 1288 | |
| 1289 | - $class = 'btn btn-block submit-button ' . sanitize_html_class( $field['class'] ); |
|
| 1289 | + $class = 'btn btn-block submit-button ' . sanitize_html_class($field['class']); |
|
| 1290 | 1290 | echo aui()->input( |
| 1291 | 1291 | array( |
| 1292 | - 'name' => esc_attr( $field['id'] ), |
|
| 1293 | - 'id' => esc_attr( $field['id'] ), |
|
| 1294 | - 'value' => esc_attr( $field['label'] ), |
|
| 1292 | + 'name' => esc_attr($field['id']), |
|
| 1293 | + 'id' => esc_attr($field['id']), |
|
| 1294 | + 'value' => esc_attr($field['label']), |
|
| 1295 | 1295 | 'no_wrap' => true, |
| 1296 | 1296 | 'type' => 'submit', |
| 1297 | 1297 | 'class' => $class, |
| 1298 | 1298 | ) |
| 1299 | 1299 | ); |
| 1300 | 1300 | |
| 1301 | - if ( ! empty( $field['description'] ) ) { |
|
| 1302 | - $description = wp_kses_post( $field['description'] ); |
|
| 1301 | + if (!empty($field['description'])) { |
|
| 1302 | + $description = wp_kses_post($field['description']); |
|
| 1303 | 1303 | echo "<small class='form-text text-muted'>$description</small>"; |
| 1304 | 1304 | } |
| 1305 | 1305 | |
@@ -1310,14 +1310,14 @@ discard block |
||
| 1310 | 1310 | /** |
| 1311 | 1311 | * Renders the pay button element template. |
| 1312 | 1312 | */ |
| 1313 | - public function edit_pay_button_template( $field ) { |
|
| 1314 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
| 1315 | - $label = __( 'Button Text', 'invoicing' ); |
|
| 1313 | + public function edit_pay_button_template($field) { |
|
| 1314 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
| 1315 | + $label = __('Button Text', 'invoicing'); |
|
| 1316 | 1316 | $id = $field . '.id + "_edit"'; |
| 1317 | - $label2 = __( 'Help text', 'invoicing' ); |
|
| 1318 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1317 | + $label2 = __('Help text', 'invoicing'); |
|
| 1318 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1319 | 1319 | $id2 = $field . '.id + "_edit2"'; |
| 1320 | - $label4 = esc_attr__( 'Button Type', 'invoicing' ); |
|
| 1320 | + $label4 = esc_attr__('Button Type', 'invoicing'); |
|
| 1321 | 1321 | $id3 = $field . '.id + "_edit3"'; |
| 1322 | 1322 | echo " |
| 1323 | 1323 | <div $restrict> |
@@ -1333,15 +1333,15 @@ discard block |
||
| 1333 | 1333 | <label :for='$id3'>$label4</label> |
| 1334 | 1334 | |
| 1335 | 1335 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
| 1336 | - <option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
| 1337 | - <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
| 1338 | - <option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
| 1339 | - <option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
| 1340 | - <option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
| 1341 | - <option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
| 1342 | - <option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
| 1343 | - <option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
| 1344 | - <option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
|
| 1336 | + <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option> |
|
| 1337 | + <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
| 1338 | + <option value='btn-success'>" . __('Success', 'invoicing') . "</option> |
|
| 1339 | + <option value='btn-danger'>" . __('Danger', 'invoicing') . "</option> |
|
| 1340 | + <option value='btn-warning'>" . __('Warning', 'invoicing') . "</option> |
|
| 1341 | + <option value='btn-info'>" . __('Info', 'invoicing') . "</option> |
|
| 1342 | + <option value='btn-light'>" . __('Light', 'invoicing') . "</option> |
|
| 1343 | + <option value='btn-dark'>" . __('Dark', 'invoicing') . "</option> |
|
| 1344 | + <option value='btn-link'>" . __('Link', 'invoicing') . "</option> |
|
| 1345 | 1345 | </select> |
| 1346 | 1346 | </div> |
| 1347 | 1347 | </div> |
@@ -1352,8 +1352,8 @@ discard block |
||
| 1352 | 1352 | /** |
| 1353 | 1353 | * Renders the alert element template. |
| 1354 | 1354 | */ |
| 1355 | - public function render_alert_template( $field ) { |
|
| 1356 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
| 1355 | + public function render_alert_template($field) { |
|
| 1356 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
| 1357 | 1357 | $text = "$field.text"; |
| 1358 | 1358 | echo " |
| 1359 | 1359 | <div $restrict class='alert' :class='$field.class' role='alert'> |
@@ -1368,15 +1368,15 @@ discard block |
||
| 1368 | 1368 | /** |
| 1369 | 1369 | * Renders the alert element on the frontend. |
| 1370 | 1370 | */ |
| 1371 | - public function frontend_render_alert_template( $field ) { |
|
| 1371 | + public function frontend_render_alert_template($field) { |
|
| 1372 | 1372 | |
| 1373 | 1373 | echo "<div class='form-group'>"; |
| 1374 | 1374 | |
| 1375 | 1375 | echo aui()->alert( |
| 1376 | 1376 | array( |
| 1377 | - 'content' => wp_kses_post( $field['text'] ), |
|
| 1377 | + 'content' => wp_kses_post($field['text']), |
|
| 1378 | 1378 | 'dismissible' => $field['dismissible'], |
| 1379 | - 'type' => str_replace( 'alert-', '', $field['class'] ), |
|
| 1379 | + 'type' => str_replace('alert-', '', $field['class']), |
|
| 1380 | 1380 | ) |
| 1381 | 1381 | ); |
| 1382 | 1382 | |
@@ -1387,14 +1387,14 @@ discard block |
||
| 1387 | 1387 | /** |
| 1388 | 1388 | * Renders the alert element template. |
| 1389 | 1389 | */ |
| 1390 | - public function edit_alert_template( $field ) { |
|
| 1391 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
| 1392 | - $label = __( 'Alert Text', 'invoicing' ); |
|
| 1393 | - $label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
|
| 1390 | + public function edit_alert_template($field) { |
|
| 1391 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
| 1392 | + $label = __('Alert Text', 'invoicing'); |
|
| 1393 | + $label2 = esc_attr__('Enter your alert text here', 'invoicing'); |
|
| 1394 | 1394 | $id = $field . '.id + "_edit"'; |
| 1395 | - $label3 = __( 'Is Dismissible?', 'invoicing' ); |
|
| 1395 | + $label3 = __('Is Dismissible?', 'invoicing'); |
|
| 1396 | 1396 | $id2 = $field . '.id + "_edit2"'; |
| 1397 | - $label4 = esc_attr__( 'Alert Type', 'invoicing' ); |
|
| 1397 | + $label4 = esc_attr__('Alert Type', 'invoicing'); |
|
| 1398 | 1398 | $id3 = $field . '.id + "_edit3"'; |
| 1399 | 1399 | echo " |
| 1400 | 1400 | <div $restrict> |
@@ -1410,14 +1410,14 @@ discard block |
||
| 1410 | 1410 | <label :for='$id3'>$label4</label> |
| 1411 | 1411 | |
| 1412 | 1412 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
| 1413 | - <option value='alert-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
| 1414 | - <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
| 1415 | - <option value='alert-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
| 1416 | - <option value='alert-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
| 1417 | - <option value='alert-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
| 1418 | - <option value='alert-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
| 1419 | - <option value='alert-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
| 1420 | - <option value='alert-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
| 1413 | + <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option> |
|
| 1414 | + <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
| 1415 | + <option value='alert-success'>" . __('Success', 'invoicing') . "</option> |
|
| 1416 | + <option value='alert-danger'>" . __('Danger', 'invoicing') . "</option> |
|
| 1417 | + <option value='alert-warning'>" . __('Warning', 'invoicing') . "</option> |
|
| 1418 | + <option value='alert-info'>" . __('Info', 'invoicing') . "</option> |
|
| 1419 | + <option value='alert-light'>" . __('Light', 'invoicing') . "</option> |
|
| 1420 | + <option value='alert-dark'>" . __('Dark', 'invoicing') . "</option> |
|
| 1421 | 1421 | </select> |
| 1422 | 1422 | </div> |
| 1423 | 1423 | </div> |
@@ -1428,8 +1428,8 @@ discard block |
||
| 1428 | 1428 | /** |
| 1429 | 1429 | * Renders the discount element template. |
| 1430 | 1430 | */ |
| 1431 | - public function render_discount_template( $field ) { |
|
| 1432 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
| 1431 | + public function render_discount_template($field) { |
|
| 1432 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
| 1433 | 1433 | ?> |
| 1434 | 1434 | |
| 1435 | 1435 | <div <?php echo $restrict; ?> class="discount_field border rounded p-3"> |
@@ -1446,13 +1446,13 @@ discard block |
||
| 1446 | 1446 | /** |
| 1447 | 1447 | * Renders the discount element on the frontend. |
| 1448 | 1448 | */ |
| 1449 | - public function frontend_render_discount_template( $field ) { |
|
| 1449 | + public function frontend_render_discount_template($field) { |
|
| 1450 | 1450 | |
| 1451 | - $placeholder = esc_attr( $field['input_label'] ); |
|
| 1452 | - $label = sanitize_text_field( $field['button_label'] ); |
|
| 1451 | + $placeholder = esc_attr($field['input_label']); |
|
| 1452 | + $label = sanitize_text_field($field['button_label']); |
|
| 1453 | 1453 | $description = ''; |
| 1454 | 1454 | |
| 1455 | - if ( ! empty( $field['description'] ) ) { |
|
| 1455 | + if (!empty($field['description'])) { |
|
| 1456 | 1456 | $description = "<small class='form-text text-muted'>{$field['description']}</small>"; |
| 1457 | 1457 | } |
| 1458 | 1458 | ?> |
@@ -1473,12 +1473,12 @@ discard block |
||
| 1473 | 1473 | /** |
| 1474 | 1474 | * Renders the discount element template. |
| 1475 | 1475 | */ |
| 1476 | - public function edit_discount_template( $field ) { |
|
| 1477 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
| 1478 | - $label = __( 'Discount Input Placeholder', 'invoicing' ); |
|
| 1479 | - $label2 = __( 'Help Text', 'invoicing' ); |
|
| 1480 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
| 1481 | - $label4 = __( 'Button Text', 'invoicing' ); |
|
| 1476 | + public function edit_discount_template($field) { |
|
| 1477 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
| 1478 | + $label = __('Discount Input Placeholder', 'invoicing'); |
|
| 1479 | + $label2 = __('Help Text', 'invoicing'); |
|
| 1480 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
| 1481 | + $label4 = __('Button Text', 'invoicing'); |
|
| 1482 | 1482 | $id = $field . '.id + "_edit"'; |
| 1483 | 1483 | $id2 = $field . '.id + "_edit2"'; |
| 1484 | 1484 | $id3 = $field . '.id + "_edit3"'; |
@@ -1507,8 +1507,8 @@ discard block |
||
| 1507 | 1507 | /** |
| 1508 | 1508 | * Renders the items element template. |
| 1509 | 1509 | */ |
| 1510 | - public function render_items_template( $field ) { |
|
| 1511 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
| 1510 | + public function render_items_template($field) { |
|
| 1511 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
| 1512 | 1512 | echo " |
| 1513 | 1513 | <div $restrict class='item_totals'> |
| 1514 | 1514 | |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | <div v-if='$field.items_type == \"select\"'> |
| 1554 | 1554 | |
| 1555 | 1555 | <select class='form-control custom-select'> |
| 1556 | - <option value='' disabled selected='selected'>" . __( 'Select an option', 'invoicing' ) ."</option> |
|
| 1556 | + <option value='' disabled selected='selected'>" . __('Select an option', 'invoicing') . "</option> |
|
| 1557 | 1557 | <option v-for='(item, index) in form_items' :value='index'>{{item.title}} {{formatPrice(item.price)}}</option> |
| 1558 | 1558 | </select> |
| 1559 | 1559 | </div> |
@@ -1574,66 +1574,66 @@ discard block |
||
| 1574 | 1574 | /** |
| 1575 | 1575 | * Renders the items element on the frontend. |
| 1576 | 1576 | */ |
| 1577 | - public function frontend_render_items_template( $field, $items ) { |
|
| 1577 | + public function frontend_render_items_template($field, $items) { |
|
| 1578 | 1578 | |
| 1579 | 1579 | echo "<div class='form-group item_totals'>"; |
| 1580 | 1580 | |
| 1581 | - $id = esc_attr( $field['id'] ); |
|
| 1582 | - if ( 'total' == $field[ 'items_type' ] ) { |
|
| 1581 | + $id = esc_attr($field['id']); |
|
| 1582 | + if ('total' == $field['items_type']) { |
|
| 1583 | 1583 | $total = 0; |
| 1584 | 1584 | |
| 1585 | 1585 | ?> |
| 1586 | 1586 | <div class="border item_totals_type_total"> |
| 1587 | 1587 | |
| 1588 | 1588 | <?php |
| 1589 | - foreach( $items as $item ) { |
|
| 1590 | - $total = $total + floatval( $item['price'] ); |
|
| 1589 | + foreach ($items as $item) { |
|
| 1590 | + $total = $total + floatval($item['price']); |
|
| 1591 | 1591 | ?> |
| 1592 | 1592 | <div class="item_totals_item"> |
| 1593 | 1593 | <div class='row pl-2 pr-2 pt-2'> |
| 1594 | - <div class='col-8'><?php echo esc_html( $item['title'] ) ?></div> |
|
| 1595 | - <div class='col-4'><?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?></div> |
|
| 1594 | + <div class='col-8'><?php echo esc_html($item['title']) ?></div> |
|
| 1595 | + <div class='col-4'><?php echo wpinv_price(wpinv_format_amount($item['price'])) ?></div> |
|
| 1596 | 1596 | </div> |
| 1597 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 1598 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 1597 | + <?php if (!empty($item['description'])) { ?> |
|
| 1598 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 1599 | 1599 | <?php } ?> |
| 1600 | 1600 | </div> |
| 1601 | 1601 | <?php } ?> |
| 1602 | 1602 | |
| 1603 | 1603 | <div class='mt-4 border-top item_totals_total'> |
| 1604 | 1604 | <div class='row p-2'> |
| 1605 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
| 1606 | - <div class='col-4'><strong><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
| 1605 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
| 1606 | + <div class='col-4'><strong><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
| 1607 | 1607 | </div> |
| 1608 | 1608 | </div> |
| 1609 | 1609 | |
| 1610 | 1610 | </div> |
| 1611 | 1611 | <?php } ?> |
| 1612 | 1612 | |
| 1613 | - <?php if ( 'radio' == $field[ 'items_type' ] ) { ?> |
|
| 1613 | + <?php if ('radio' == $field['items_type']) { ?> |
|
| 1614 | 1614 | <div class="item_totals_type_radio"> |
| 1615 | 1615 | |
| 1616 | - <?php foreach( $items as $index => $item ) { ?> |
|
| 1616 | + <?php foreach ($items as $index => $item) { ?> |
|
| 1617 | 1617 | <div class="form-check"> |
| 1618 | 1618 | <input class='form-check-input' type='radio' name='<?php echo $id; ?>' id='<?php echo $id . $index; ?>'> |
| 1619 | - <label class='form-check-label' for=<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?> <strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); ?></strong></label> |
|
| 1619 | + <label class='form-check-label' for=<?php echo $id . $index; ?>'><?php echo sanitize_text_field($item['title']); ?> <strong><?php echo wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); ?></strong></label> |
|
| 1620 | 1620 | </div> |
| 1621 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
| 1622 | - <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
| 1621 | + <?php if (!empty($item['description'])) { ?> |
|
| 1622 | + <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
| 1623 | 1623 | <?php } ?> |
| 1624 | 1624 | <?php } ?> |
| 1625 | 1625 | |
| 1626 | 1626 | </div> |
| 1627 | 1627 | <?php } ?> |
| 1628 | 1628 | |
| 1629 | - <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?> |
|
| 1629 | + <?php if ('checkbox' == $field['items_type']) { ?> |
|
| 1630 | 1630 | |
| 1631 | 1631 | <div class="item_totals_type_checkbox"> |
| 1632 | 1632 | |
| 1633 | 1633 | <?php |
| 1634 | - foreach ( $items as $index => $item ) { |
|
| 1635 | - $title = sanitize_text_field( $item['title'] ); |
|
| 1636 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
| 1634 | + foreach ($items as $index => $item) { |
|
| 1635 | + $title = sanitize_text_field($item['title']); |
|
| 1636 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
| 1637 | 1637 | echo aui()->input( |
| 1638 | 1638 | array( |
| 1639 | 1639 | 'name' => $id, |
@@ -1644,7 +1644,7 @@ discard block |
||
| 1644 | 1644 | ) |
| 1645 | 1645 | ); |
| 1646 | 1646 | |
| 1647 | - if ( ! empty( $item['description'] ) ) { |
|
| 1647 | + if (!empty($item['description'])) { |
|
| 1648 | 1648 | echo "<small class='form-text text-muted'>{$item['description']}</small>"; |
| 1649 | 1649 | } |
| 1650 | 1650 | } |
@@ -1653,7 +1653,7 @@ discard block |
||
| 1653 | 1653 | </div> |
| 1654 | 1654 | <?php } ?> |
| 1655 | 1655 | |
| 1656 | - <?php if ( 'select' == $field[ 'items_type' ] ) { ?> |
|
| 1656 | + <?php if ('select' == $field['items_type']) { ?> |
|
| 1657 | 1657 | |
| 1658 | 1658 | <div class="item_totals_type_select"> |
| 1659 | 1659 | |
@@ -1661,17 +1661,17 @@ discard block |
||
| 1661 | 1661 | |
| 1662 | 1662 | $options = array(); |
| 1663 | 1663 | |
| 1664 | - foreach ( $items as $index => $item ) { |
|
| 1665 | - $title = sanitize_text_field( $item['title'] ); |
|
| 1666 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
| 1667 | - $options[ $item['id'] ] = "$title ($price)"; |
|
| 1664 | + foreach ($items as $index => $item) { |
|
| 1665 | + $title = sanitize_text_field($item['title']); |
|
| 1666 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
| 1667 | + $options[$item['id']] = "$title ($price)"; |
|
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | 1670 | echo aui()->select( |
| 1671 | 1671 | array( |
| 1672 | 1672 | 'name' => $id, |
| 1673 | 1673 | 'id' => $id, |
| 1674 | - 'placeholder' => __( 'Select an item', 'invoicing' ), |
|
| 1674 | + 'placeholder' => __('Select an item', 'invoicing'), |
|
| 1675 | 1675 | 'no_wrap' => true, |
| 1676 | 1676 | 'options' => $options, |
| 1677 | 1677 | 'class' => 'wpi_select2' |
@@ -1682,7 +1682,7 @@ discard block |
||
| 1682 | 1682 | </div> |
| 1683 | 1683 | <?php } ?> |
| 1684 | 1684 | |
| 1685 | - <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?> |
|
| 1685 | + <?php if ('multi_select' == $field['items_type']) { ?> |
|
| 1686 | 1686 | |
| 1687 | 1687 | <div class="item_totals_type_multi_select"> |
| 1688 | 1688 | |
@@ -1690,17 +1690,17 @@ discard block |
||
| 1690 | 1690 | |
| 1691 | 1691 | $options = array(); |
| 1692 | 1692 | |
| 1693 | - foreach ( $items as $index => $item ) { |
|
| 1694 | - $title = sanitize_text_field( $item['title'] ); |
|
| 1695 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
| 1696 | - $options[ $item['id'] ] = "$title ($price)"; |
|
| 1693 | + foreach ($items as $index => $item) { |
|
| 1694 | + $title = sanitize_text_field($item['title']); |
|
| 1695 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
| 1696 | + $options[$item['id']] = "$title ($price)"; |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | 1699 | echo aui()->select( |
| 1700 | 1700 | array( |
| 1701 | 1701 | 'name' => $id, |
| 1702 | 1702 | 'id' => $id, |
| 1703 | - 'placeholder' => __( 'Select one or more items', 'invoicing' ), |
|
| 1703 | + 'placeholder' => __('Select one or more items', 'invoicing'), |
|
| 1704 | 1704 | 'no_wrap' => true, |
| 1705 | 1705 | 'options' => $options, |
| 1706 | 1706 | 'multiple' => true, |
@@ -1719,11 +1719,11 @@ discard block |
||
| 1719 | 1719 | /** |
| 1720 | 1720 | * Renders the items element template. |
| 1721 | 1721 | */ |
| 1722 | - public function edit_items_template( $field ) { |
|
| 1723 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
| 1724 | - $label = __( 'Let customers...', 'invoicing' ); |
|
| 1725 | - $label2 = __( 'Available Items', 'invoicing' ); |
|
| 1726 | - $label3 = esc_attr__( 'Add some help text for this element', 'invoicing' ); |
|
| 1722 | + public function edit_items_template($field) { |
|
| 1723 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
| 1724 | + $label = __('Let customers...', 'invoicing'); |
|
| 1725 | + $label2 = __('Available Items', 'invoicing'); |
|
| 1726 | + $label3 = esc_attr__('Add some help text for this element', 'invoicing'); |
|
| 1727 | 1727 | $id = $field . '.id + "_edit"'; |
| 1728 | 1728 | $id2 = $field . '.id + "_edit2"'; |
| 1729 | 1729 | $id3 = $field . '.id + "_edit3"'; |
@@ -1775,7 +1775,7 @@ discard block |
||
| 1775 | 1775 | <div class='form-group mt-2'> |
| 1776 | 1776 | |
| 1777 | 1777 | <select class='form-control custom-select' v-model='selected_item'> |
| 1778 | - <option value=''>" . __( 'Add an item to the form', 'invoicing' ) ."</option> |
|
| 1778 | + <option value=''>" . __('Add an item to the form', 'invoicing') . "</option> |
|
| 1779 | 1779 | <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option> |
| 1780 | 1780 | </select> |
| 1781 | 1781 | |
@@ -1790,11 +1790,11 @@ discard block |
||
| 1790 | 1790 | <label :for='$id2'>$label</label> |
| 1791 | 1791 | |
| 1792 | 1792 | <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'> |
| 1793 | - <option value='total'>" . __( 'Buy all items on the list', 'invoicing' ) ."</option> |
|
| 1794 | - <option value='radio'>" . __( 'Select a single item from the list', 'invoicing' ) ."</option> |
|
| 1795 | - <option value='checkbox'>" . __( 'Select one or more items on the list', 'invoicing' ) ."</option> |
|
| 1796 | - <option value='select'>" . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option> |
|
| 1797 | - <option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option> |
|
| 1793 | + <option value='total'>" . __('Buy all items on the list', 'invoicing') . "</option> |
|
| 1794 | + <option value='radio'>" . __('Select a single item from the list', 'invoicing') . "</option> |
|
| 1795 | + <option value='checkbox'>" . __('Select one or more items on the list', 'invoicing') . "</option> |
|
| 1796 | + <option value='select'>" . __('Select a single item from a dropdown', 'invoicing') . "</option> |
|
| 1797 | + <option value='multi_select'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option> |
|
| 1798 | 1798 | </select> |
| 1799 | 1799 | |
| 1800 | 1800 | </div> |
@@ -1819,24 +1819,24 @@ discard block |
||
| 1819 | 1819 | 'orderby' => 'title', |
| 1820 | 1820 | 'order' => 'ASC', |
| 1821 | 1821 | 'posts_per_page' => -1, |
| 1822 | - 'post_status' => array( 'publish' ), |
|
| 1822 | + 'post_status' => array('publish'), |
|
| 1823 | 1823 | ); |
| 1824 | 1824 | |
| 1825 | - $items = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) ); |
|
| 1825 | + $items = get_posts(apply_filters('wpinv_item_dropdown_query_args', $item_args)); |
|
| 1826 | 1826 | |
| 1827 | - if ( empty( $items ) ) { |
|
| 1827 | + if (empty($items)) { |
|
| 1828 | 1828 | return array(); |
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | - $options = array(); |
|
| 1832 | - foreach ( $items as $item ) { |
|
| 1833 | - $title = esc_html( $item->post_title ); |
|
| 1834 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 1835 | - $id = absint( $item->ID ); |
|
| 1836 | - $price = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) ); |
|
| 1837 | - $recurring = (bool) get_post_meta( $id, '_wpinv_is_recurring', true ); |
|
| 1831 | + $options = array(); |
|
| 1832 | + foreach ($items as $item) { |
|
| 1833 | + $title = esc_html($item->post_title); |
|
| 1834 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 1835 | + $id = absint($item->ID); |
|
| 1836 | + $price = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true)); |
|
| 1837 | + $recurring = (bool) get_post_meta($id, '_wpinv_is_recurring', true); |
|
| 1838 | 1838 | $description = $item->post_excerpt; |
| 1839 | - $options[] = compact( 'title', 'id', 'price', 'recurring', 'description' ); |
|
| 1839 | + $options[] = compact('title', 'id', 'price', 'recurring', 'description'); |
|
| 1840 | 1840 | |
| 1841 | 1841 | } |
| 1842 | 1842 | return $options; |
@@ -1846,38 +1846,38 @@ discard block |
||
| 1846 | 1846 | /** |
| 1847 | 1847 | * Returns an array of items for the currently being edited form. |
| 1848 | 1848 | */ |
| 1849 | - public function get_form_items( $id = false ) { |
|
| 1849 | + public function get_form_items($id = false) { |
|
| 1850 | 1850 | |
| 1851 | - if ( empty( $id ) ) { |
|
| 1852 | - return wpinv_get_data( 'sample-payment-form-items' ); |
|
| 1851 | + if (empty($id)) { |
|
| 1852 | + return wpinv_get_data('sample-payment-form-items'); |
|
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | - $form_elements = get_post_meta( $id, 'wpinv_form_items', true ); |
|
| 1855 | + $form_elements = get_post_meta($id, 'wpinv_form_items', true); |
|
| 1856 | 1856 | |
| 1857 | - if ( is_array( $form_elements ) ) { |
|
| 1857 | + if (is_array($form_elements)) { |
|
| 1858 | 1858 | return $form_elements; |
| 1859 | 1859 | } |
| 1860 | 1860 | |
| 1861 | - return wpinv_get_data( 'sample-payment-form-items' ); |
|
| 1861 | + return wpinv_get_data('sample-payment-form-items'); |
|
| 1862 | 1862 | |
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | 1865 | /** |
| 1866 | 1866 | * Returns an array of elements for the currently being edited form. |
| 1867 | 1867 | */ |
| 1868 | - public function get_form_elements( $id = false ) { |
|
| 1868 | + public function get_form_elements($id = false) { |
|
| 1869 | 1869 | |
| 1870 | - if ( empty( $id ) ) { |
|
| 1871 | - return wpinv_get_data( 'sample-payment-form' ); |
|
| 1870 | + if (empty($id)) { |
|
| 1871 | + return wpinv_get_data('sample-payment-form'); |
|
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | - $form_elements = get_post_meta( $id, 'wpinv_form_elements', true ); |
|
| 1874 | + $form_elements = get_post_meta($id, 'wpinv_form_elements', true); |
|
| 1875 | 1875 | |
| 1876 | - if ( is_array( $form_elements ) ) { |
|
| 1876 | + if (is_array($form_elements)) { |
|
| 1877 | 1877 | return $form_elements; |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | - return wpinv_get_data( 'sample-payment-form' ); |
|
| 1880 | + return wpinv_get_data('sample-payment-form'); |
|
| 1881 | 1881 | } |
| 1882 | 1882 | |
| 1883 | 1883 | } |