@@ -15,331 +15,331 @@ |
||
| 15 | 15 | class GetPaid_Post_Types { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Hook in methods. |
|
| 19 | - */ |
|
| 20 | - public function __construct() { |
|
| 21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
| 22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
| 23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
| 25 | - } |
|
| 18 | + * Hook in methods. |
|
| 19 | + */ |
|
| 20 | + public function __construct() { |
|
| 21 | + add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
| 22 | + add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
| 23 | + add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 24 | + add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Register core post types. |
|
| 29 | - */ |
|
| 30 | - public static function register_post_types() { |
|
| 27 | + /** |
|
| 28 | + * Register core post types. |
|
| 29 | + */ |
|
| 30 | + public static function register_post_types() { |
|
| 31 | 31 | |
| 32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
| 33 | - return; |
|
| 34 | - } |
|
| 32 | + if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
| 33 | + return; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
| 36 | + $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
| 37 | 37 | |
| 38 | - // Fires before registering post types. |
|
| 39 | - do_action( 'getpaid_register_post_types' ); |
|
| 38 | + // Fires before registering post types. |
|
| 39 | + do_action( 'getpaid_register_post_types' ); |
|
| 40 | 40 | |
| 41 | - // Register item post type. |
|
| 42 | - register_post_type( |
|
| 43 | - 'wpi_item', |
|
| 44 | - apply_filters( |
|
| 45 | - 'wpinv_register_post_type_invoice_item', |
|
| 46 | - array( |
|
| 47 | - 'labels' => array( |
|
| 48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
| 49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
| 50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
| 51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
| 52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
| 53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
| 54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
| 55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
| 56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
| 57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
| 58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
| 59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
| 60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
| 61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
| 62 | - ), |
|
| 63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
| 64 | - 'public' => false, |
|
| 65 | - 'has_archive' => false, |
|
| 66 | - '_builtin' => false, |
|
| 67 | - 'show_ui' => true, |
|
| 68 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
| 69 | - 'show_in_nav_menus' => false, |
|
| 70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
| 71 | - 'rewrite' => false, |
|
| 72 | - 'query_var' => false, |
|
| 73 | - 'map_meta_cap' => true, |
|
| 74 | - 'show_in_admin_bar' => true, |
|
| 75 | - 'can_export' => true, |
|
| 76 | - ) |
|
| 77 | - ) |
|
| 78 | - ); |
|
| 41 | + // Register item post type. |
|
| 42 | + register_post_type( |
|
| 43 | + 'wpi_item', |
|
| 44 | + apply_filters( |
|
| 45 | + 'wpinv_register_post_type_invoice_item', |
|
| 46 | + array( |
|
| 47 | + 'labels' => array( |
|
| 48 | + 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
| 49 | + 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
| 50 | + 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
| 51 | + 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
| 52 | + 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
| 53 | + 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
| 54 | + 'new_item' => __( 'New Item', 'invoicing' ), |
|
| 55 | + 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
| 56 | + 'view_item' => __( 'View Item', 'invoicing' ), |
|
| 57 | + 'all_items' => __( 'Items', 'invoicing' ), |
|
| 58 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
| 59 | + 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
| 60 | + 'not_found' => __( 'No items found.', 'invoicing' ), |
|
| 61 | + 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
| 62 | + ), |
|
| 63 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
| 64 | + 'public' => false, |
|
| 65 | + 'has_archive' => false, |
|
| 66 | + '_builtin' => false, |
|
| 67 | + 'show_ui' => true, |
|
| 68 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
| 69 | + 'show_in_nav_menus' => false, |
|
| 70 | + 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
| 71 | + 'rewrite' => false, |
|
| 72 | + 'query_var' => false, |
|
| 73 | + 'map_meta_cap' => true, |
|
| 74 | + 'show_in_admin_bar' => true, |
|
| 75 | + 'can_export' => true, |
|
| 76 | + ) |
|
| 77 | + ) |
|
| 78 | + ); |
|
| 79 | 79 | |
| 80 | - // Register payment form post type. |
|
| 81 | - register_post_type( |
|
| 82 | - 'wpi_payment_form', |
|
| 83 | - apply_filters( |
|
| 84 | - 'wpinv_register_post_type_payment_form', |
|
| 85 | - array( |
|
| 86 | - 'labels' => array( |
|
| 87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
| 88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
| 89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
| 90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
| 91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
| 92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
| 93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
| 94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
| 95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
| 96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
| 97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
| 98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
| 99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
| 100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
| 101 | - ), |
|
| 102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
| 103 | - 'public' => false, |
|
| 104 | - 'show_ui' => true, |
|
| 105 | - 'show_in_menu' => $capabilities ? 'wpinv' : true, |
|
| 106 | - 'show_in_nav_menus' => false, |
|
| 107 | - 'query_var' => false, |
|
| 108 | - 'rewrite' => true, |
|
| 109 | - 'map_meta_cap' => true, |
|
| 110 | - 'has_archive' => false, |
|
| 111 | - 'hierarchical' => false, |
|
| 112 | - 'menu_position' => null, |
|
| 113 | - 'supports' => array( 'title' ), |
|
| 114 | - 'menu_icon' => 'dashicons-media-form', |
|
| 115 | - 'capabilities' => array( |
|
| 116 | - 'edit_post' => $capabilities, |
|
| 117 | - 'read_post' => $capabilities, |
|
| 118 | - 'delete_post' => $capabilities, |
|
| 119 | - 'edit_posts' => 'update_core', |
|
| 120 | - 'edit_others_posts' => 'update_core', |
|
| 121 | - 'delete_posts' => 'update_core', |
|
| 122 | - 'publish_posts' => 'update_core', |
|
| 123 | - 'read_private_posts' => 'update_core' |
|
| 124 | - ), |
|
| 125 | - ) |
|
| 126 | - ) |
|
| 127 | - ); |
|
| 80 | + // Register payment form post type. |
|
| 81 | + register_post_type( |
|
| 82 | + 'wpi_payment_form', |
|
| 83 | + apply_filters( |
|
| 84 | + 'wpinv_register_post_type_payment_form', |
|
| 85 | + array( |
|
| 86 | + 'labels' => array( |
|
| 87 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
| 88 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
| 89 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
| 90 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
| 91 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
| 92 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
| 93 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
| 94 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
| 95 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
| 96 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
| 97 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
| 98 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
| 99 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
| 100 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
| 101 | + ), |
|
| 102 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
| 103 | + 'public' => false, |
|
| 104 | + 'show_ui' => true, |
|
| 105 | + 'show_in_menu' => $capabilities ? 'wpinv' : true, |
|
| 106 | + 'show_in_nav_menus' => false, |
|
| 107 | + 'query_var' => false, |
|
| 108 | + 'rewrite' => true, |
|
| 109 | + 'map_meta_cap' => true, |
|
| 110 | + 'has_archive' => false, |
|
| 111 | + 'hierarchical' => false, |
|
| 112 | + 'menu_position' => null, |
|
| 113 | + 'supports' => array( 'title' ), |
|
| 114 | + 'menu_icon' => 'dashicons-media-form', |
|
| 115 | + 'capabilities' => array( |
|
| 116 | + 'edit_post' => $capabilities, |
|
| 117 | + 'read_post' => $capabilities, |
|
| 118 | + 'delete_post' => $capabilities, |
|
| 119 | + 'edit_posts' => 'update_core', |
|
| 120 | + 'edit_others_posts' => 'update_core', |
|
| 121 | + 'delete_posts' => 'update_core', |
|
| 122 | + 'publish_posts' => 'update_core', |
|
| 123 | + 'read_private_posts' => 'update_core' |
|
| 124 | + ), |
|
| 125 | + ) |
|
| 126 | + ) |
|
| 127 | + ); |
|
| 128 | 128 | |
| 129 | - // Register invoice post type. |
|
| 130 | - register_post_type( |
|
| 131 | - 'wpi_invoice', |
|
| 132 | - apply_filters( |
|
| 133 | - 'wpinv_register_post_type_invoice', |
|
| 134 | - array( |
|
| 135 | - 'labels' => array( |
|
| 136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
| 137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
| 138 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
| 139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
| 140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
| 141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
| 142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
| 143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
| 144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
| 145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
| 146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
| 147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
| 148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
| 149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
| 150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
| 151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
| 152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
| 153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
| 154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
| 155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
| 156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
| 157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
| 158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
| 159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
| 160 | - ), |
|
| 161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
| 162 | - 'public' => true, |
|
| 163 | - 'has_archive' => false, |
|
| 164 | - 'publicly_queryable' => true, |
|
| 165 | - 'exclude_from_search' => true, |
|
| 166 | - 'show_ui' => true, |
|
| 167 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
| 168 | - 'show_in_nav_menus' => false, |
|
| 169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
| 170 | - 'rewrite' => array( |
|
| 171 | - 'slug' => 'invoice', |
|
| 172 | - 'with_front' => false, |
|
| 173 | - ), |
|
| 174 | - 'query_var' => false, |
|
| 175 | - 'map_meta_cap' => true, |
|
| 176 | - 'show_in_admin_bar' => true, |
|
| 177 | - 'can_export' => true, |
|
| 178 | - 'hierarchical' => false, |
|
| 179 | - 'menu_position' => null, |
|
| 180 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
| 181 | - ) |
|
| 182 | - ) |
|
| 183 | - ); |
|
| 129 | + // Register invoice post type. |
|
| 130 | + register_post_type( |
|
| 131 | + 'wpi_invoice', |
|
| 132 | + apply_filters( |
|
| 133 | + 'wpinv_register_post_type_invoice', |
|
| 134 | + array( |
|
| 135 | + 'labels' => array( |
|
| 136 | + 'name' => __( 'Invoices', 'invoicing' ), |
|
| 137 | + 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
| 138 | + 'all_items' => __( 'Invoices', 'invoicing' ), |
|
| 139 | + 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
| 140 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
| 141 | + 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
| 142 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
| 143 | + 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
| 144 | + 'new_item' => __( 'New invoice', 'invoicing' ), |
|
| 145 | + 'view_item' => __( 'View invoice', 'invoicing' ), |
|
| 146 | + 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
| 147 | + 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
| 148 | + 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
| 149 | + 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
| 150 | + 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
| 151 | + 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
| 152 | + 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
| 153 | + 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
| 154 | + 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
| 155 | + 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
| 156 | + 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
| 157 | + 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
| 158 | + 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
| 159 | + 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
| 160 | + ), |
|
| 161 | + 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
| 162 | + 'public' => true, |
|
| 163 | + 'has_archive' => false, |
|
| 164 | + 'publicly_queryable' => true, |
|
| 165 | + 'exclude_from_search' => true, |
|
| 166 | + 'show_ui' => true, |
|
| 167 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
| 168 | + 'show_in_nav_menus' => false, |
|
| 169 | + 'supports' => array( 'title', 'author', 'excerpt' ), |
|
| 170 | + 'rewrite' => array( |
|
| 171 | + 'slug' => 'invoice', |
|
| 172 | + 'with_front' => false, |
|
| 173 | + ), |
|
| 174 | + 'query_var' => false, |
|
| 175 | + 'map_meta_cap' => true, |
|
| 176 | + 'show_in_admin_bar' => true, |
|
| 177 | + 'can_export' => true, |
|
| 178 | + 'hierarchical' => false, |
|
| 179 | + 'menu_position' => null, |
|
| 180 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
| 181 | + ) |
|
| 182 | + ) |
|
| 183 | + ); |
|
| 184 | 184 | |
| 185 | - // Register discount post type. |
|
| 186 | - register_post_type( |
|
| 187 | - 'wpi_discount', |
|
| 188 | - apply_filters( |
|
| 189 | - 'wpinv_register_post_type_discount', |
|
| 190 | - array( |
|
| 191 | - 'labels' => array( |
|
| 192 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
| 193 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
| 194 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
| 195 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
| 196 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
| 197 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
| 198 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
| 199 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
| 200 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
| 201 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
| 202 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
| 203 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
| 204 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
| 205 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
| 206 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
| 207 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
| 208 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
| 209 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
| 210 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
| 211 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
| 212 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
| 213 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
| 214 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
| 215 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
| 216 | - ), |
|
| 217 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
| 218 | - 'public' => false, |
|
| 219 | - 'can_export' => true, |
|
| 220 | - '_builtin' => false, |
|
| 221 | - 'publicly_queryable' => false, |
|
| 222 | - 'exclude_from_search'=> true, |
|
| 223 | - 'show_ui' => true, |
|
| 224 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
| 225 | - 'query_var' => false, |
|
| 226 | - 'rewrite' => false, |
|
| 227 | - 'map_meta_cap' => true, |
|
| 228 | - 'has_archive' => false, |
|
| 229 | - 'hierarchical' => false, |
|
| 230 | - 'supports' => array( 'title', 'excerpt' ), |
|
| 231 | - 'show_in_nav_menus' => false, |
|
| 232 | - 'show_in_admin_bar' => true, |
|
| 233 | - 'menu_position' => null, |
|
| 234 | - ) |
|
| 235 | - ) |
|
| 236 | - ); |
|
| 185 | + // Register discount post type. |
|
| 186 | + register_post_type( |
|
| 187 | + 'wpi_discount', |
|
| 188 | + apply_filters( |
|
| 189 | + 'wpinv_register_post_type_discount', |
|
| 190 | + array( |
|
| 191 | + 'labels' => array( |
|
| 192 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
| 193 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
| 194 | + 'all_items' => __( 'Discounts', 'invoicing' ), |
|
| 195 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
| 196 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
| 197 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
| 198 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
| 199 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
| 200 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
| 201 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
| 202 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
| 203 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
| 204 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
| 205 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
| 206 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
| 207 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
| 208 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
| 209 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
| 210 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
| 211 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
| 212 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
| 213 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
| 214 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
| 215 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
| 216 | + ), |
|
| 217 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
| 218 | + 'public' => false, |
|
| 219 | + 'can_export' => true, |
|
| 220 | + '_builtin' => false, |
|
| 221 | + 'publicly_queryable' => false, |
|
| 222 | + 'exclude_from_search'=> true, |
|
| 223 | + 'show_ui' => true, |
|
| 224 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
| 225 | + 'query_var' => false, |
|
| 226 | + 'rewrite' => false, |
|
| 227 | + 'map_meta_cap' => true, |
|
| 228 | + 'has_archive' => false, |
|
| 229 | + 'hierarchical' => false, |
|
| 230 | + 'supports' => array( 'title', 'excerpt' ), |
|
| 231 | + 'show_in_nav_menus' => false, |
|
| 232 | + 'show_in_admin_bar' => true, |
|
| 233 | + 'menu_position' => null, |
|
| 234 | + ) |
|
| 235 | + ) |
|
| 236 | + ); |
|
| 237 | 237 | |
| 238 | - do_action( 'getpaid_after_register_post_types' ); |
|
| 239 | - } |
|
| 238 | + do_action( 'getpaid_after_register_post_types' ); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Register our custom post statuses. |
|
| 243 | - */ |
|
| 244 | - public static function register_post_status() { |
|
| 241 | + /** |
|
| 242 | + * Register our custom post statuses. |
|
| 243 | + */ |
|
| 244 | + public static function register_post_status() { |
|
| 245 | 245 | |
| 246 | - $invoice_statuses = apply_filters( |
|
| 247 | - 'getpaid_register_invoice_post_statuses', |
|
| 248 | - array( |
|
| 246 | + $invoice_statuses = apply_filters( |
|
| 247 | + 'getpaid_register_invoice_post_statuses', |
|
| 248 | + array( |
|
| 249 | 249 | |
| 250 | - 'wpi-pending' => array( |
|
| 251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
| 252 | - 'public' => true, |
|
| 253 | - 'exclude_from_search' => true, |
|
| 254 | - 'show_in_admin_all_list' => true, |
|
| 255 | - 'show_in_admin_status_list' => true, |
|
| 256 | - /* translators: %s: number of invoices */ |
|
| 257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
| 258 | - ), |
|
| 250 | + 'wpi-pending' => array( |
|
| 251 | + 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
| 252 | + 'public' => true, |
|
| 253 | + 'exclude_from_search' => true, |
|
| 254 | + 'show_in_admin_all_list' => true, |
|
| 255 | + 'show_in_admin_status_list' => true, |
|
| 256 | + /* translators: %s: number of invoices */ |
|
| 257 | + 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
| 258 | + ), |
|
| 259 | 259 | |
| 260 | - 'wpi-processing' => array( |
|
| 261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 262 | - 'public' => true, |
|
| 263 | - 'exclude_from_search' => true, |
|
| 264 | - 'show_in_admin_all_list' => true, |
|
| 265 | - 'show_in_admin_status_list' => true, |
|
| 266 | - /* translators: %s: number of invoices */ |
|
| 267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
| 268 | - ), |
|
| 260 | + 'wpi-processing' => array( |
|
| 261 | + 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 262 | + 'public' => true, |
|
| 263 | + 'exclude_from_search' => true, |
|
| 264 | + 'show_in_admin_all_list' => true, |
|
| 265 | + 'show_in_admin_status_list' => true, |
|
| 266 | + /* translators: %s: number of invoices */ |
|
| 267 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
| 268 | + ), |
|
| 269 | 269 | |
| 270 | - 'wpi-onhold' => array( |
|
| 271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
| 272 | - 'public' => true, |
|
| 273 | - 'exclude_from_search' => true, |
|
| 274 | - 'show_in_admin_all_list' => true, |
|
| 275 | - 'show_in_admin_status_list' => true, |
|
| 276 | - /* translators: %s: number of invoices */ |
|
| 277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
| 278 | - ), |
|
| 270 | + 'wpi-onhold' => array( |
|
| 271 | + 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
| 272 | + 'public' => true, |
|
| 273 | + 'exclude_from_search' => true, |
|
| 274 | + 'show_in_admin_all_list' => true, |
|
| 275 | + 'show_in_admin_status_list' => true, |
|
| 276 | + /* translators: %s: number of invoices */ |
|
| 277 | + 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
| 278 | + ), |
|
| 279 | 279 | |
| 280 | - 'wpi-cancelled' => array( |
|
| 281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 282 | - 'public' => true, |
|
| 283 | - 'exclude_from_search' => true, |
|
| 284 | - 'show_in_admin_all_list' => true, |
|
| 285 | - 'show_in_admin_status_list' => true, |
|
| 286 | - /* translators: %s: number of invoices */ |
|
| 287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
| 288 | - ), |
|
| 280 | + 'wpi-cancelled' => array( |
|
| 281 | + 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 282 | + 'public' => true, |
|
| 283 | + 'exclude_from_search' => true, |
|
| 284 | + 'show_in_admin_all_list' => true, |
|
| 285 | + 'show_in_admin_status_list' => true, |
|
| 286 | + /* translators: %s: number of invoices */ |
|
| 287 | + 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
| 288 | + ), |
|
| 289 | 289 | |
| 290 | - 'wpi-refunded' => array( |
|
| 291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 292 | - 'public' => true, |
|
| 293 | - 'exclude_from_search' => true, |
|
| 294 | - 'show_in_admin_all_list' => true, |
|
| 295 | - 'show_in_admin_status_list' => true, |
|
| 296 | - /* translators: %s: number of invoices */ |
|
| 297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
| 298 | - ), |
|
| 290 | + 'wpi-refunded' => array( |
|
| 291 | + 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 292 | + 'public' => true, |
|
| 293 | + 'exclude_from_search' => true, |
|
| 294 | + 'show_in_admin_all_list' => true, |
|
| 295 | + 'show_in_admin_status_list' => true, |
|
| 296 | + /* translators: %s: number of invoices */ |
|
| 297 | + 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
| 298 | + ), |
|
| 299 | 299 | |
| 300 | - 'wpi-failed' => array( |
|
| 301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 302 | - 'public' => true, |
|
| 303 | - 'exclude_from_search' => true, |
|
| 304 | - 'show_in_admin_all_list' => true, |
|
| 305 | - 'show_in_admin_status_list' => true, |
|
| 306 | - /* translators: %s: number of invoices */ |
|
| 307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
| 308 | - ), |
|
| 300 | + 'wpi-failed' => array( |
|
| 301 | + 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 302 | + 'public' => true, |
|
| 303 | + 'exclude_from_search' => true, |
|
| 304 | + 'show_in_admin_all_list' => true, |
|
| 305 | + 'show_in_admin_status_list' => true, |
|
| 306 | + /* translators: %s: number of invoices */ |
|
| 307 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
| 308 | + ), |
|
| 309 | 309 | |
| 310 | - 'wpi-renewal' => array( |
|
| 311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
| 312 | - 'public' => true, |
|
| 313 | - 'exclude_from_search' => true, |
|
| 314 | - 'show_in_admin_all_list' => true, |
|
| 315 | - 'show_in_admin_status_list' => true, |
|
| 316 | - /* translators: %s: number of invoices */ |
|
| 317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
| 318 | - ) |
|
| 319 | - ) |
|
| 320 | - ); |
|
| 310 | + 'wpi-renewal' => array( |
|
| 311 | + 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
| 312 | + 'public' => true, |
|
| 313 | + 'exclude_from_search' => true, |
|
| 314 | + 'show_in_admin_all_list' => true, |
|
| 315 | + 'show_in_admin_status_list' => true, |
|
| 316 | + /* translators: %s: number of invoices */ |
|
| 317 | + 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
| 318 | + ) |
|
| 319 | + ) |
|
| 320 | + ); |
|
| 321 | 321 | |
| 322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
| 323 | - register_post_status( $invoice_statuse, $args ); |
|
| 324 | - } |
|
| 325 | - } |
|
| 322 | + foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
| 323 | + register_post_status( $invoice_statuse, $args ); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - /** |
|
| 328 | - * Flush rewrite rules. |
|
| 329 | - */ |
|
| 330 | - public static function flush_rewrite_rules() { |
|
| 331 | - flush_rewrite_rules(); |
|
| 332 | - } |
|
| 327 | + /** |
|
| 328 | + * Flush rewrite rules. |
|
| 329 | + */ |
|
| 330 | + public static function flush_rewrite_rules() { |
|
| 331 | + flush_rewrite_rules(); |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - /** |
|
| 335 | - * Flush rules to prevent 404. |
|
| 336 | - * |
|
| 337 | - */ |
|
| 338 | - public static function maybe_flush_rewrite_rules() { |
|
| 339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
| 340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
| 341 | - self::flush_rewrite_rules(); |
|
| 342 | - } |
|
| 343 | - } |
|
| 334 | + /** |
|
| 335 | + * Flush rules to prevent 404. |
|
| 336 | + * |
|
| 337 | + */ |
|
| 338 | + public static function maybe_flush_rewrite_rules() { |
|
| 339 | + if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
| 340 | + update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
| 341 | + self::flush_rewrite_rules(); |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Post types Class |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | * Hook in methods. |
| 19 | 19 | */ |
| 20 | 20 | public function __construct() { |
| 21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
| 22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
| 23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
| 21 | + add_action('init', array(__CLASS__, 'register_post_types'), 1); |
|
| 22 | + add_action('init', array(__CLASS__, 'register_post_status'), 4); |
|
| 23 | + add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules')); |
|
| 24 | + add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules')); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public static function register_post_types() { |
| 31 | 31 | |
| 32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
| 32 | + if (!is_blog_installed() || post_type_exists('wpi_item')) { |
|
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $capabilities = wpinv_current_user_can_manage_invoicing(); |
| 37 | 37 | |
| 38 | 38 | // Fires before registering post types. |
| 39 | - do_action( 'getpaid_register_post_types' ); |
|
| 39 | + do_action('getpaid_register_post_types'); |
|
| 40 | 40 | |
| 41 | 41 | // Register item post type. |
| 42 | 42 | register_post_type( |
@@ -45,29 +45,29 @@ discard block |
||
| 45 | 45 | 'wpinv_register_post_type_invoice_item', |
| 46 | 46 | array( |
| 47 | 47 | 'labels' => array( |
| 48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
| 49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
| 50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
| 51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
| 52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
| 53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
| 54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
| 55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
| 56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
| 57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
| 58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
| 59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
| 60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
| 61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
| 48 | + 'name' => _x('Items', 'post type general name', 'invoicing'), |
|
| 49 | + 'singular_name' => _x('Item', 'post type singular name', 'invoicing'), |
|
| 50 | + 'menu_name' => _x('Items', 'admin menu', 'invoicing'), |
|
| 51 | + 'name_admin_bar' => _x('Item', 'add new on admin bar', 'invoicing'), |
|
| 52 | + 'add_new' => _x('Add New', 'Item', 'invoicing'), |
|
| 53 | + 'add_new_item' => __('Add New Item', 'invoicing'), |
|
| 54 | + 'new_item' => __('New Item', 'invoicing'), |
|
| 55 | + 'edit_item' => __('Edit Item', 'invoicing'), |
|
| 56 | + 'view_item' => __('View Item', 'invoicing'), |
|
| 57 | + 'all_items' => __('Items', 'invoicing'), |
|
| 58 | + 'search_items' => __('Search items', 'invoicing'), |
|
| 59 | + 'parent_item_colon' => __('Parent item:', 'invoicing'), |
|
| 60 | + 'not_found' => __('No items found.', 'invoicing'), |
|
| 61 | + 'not_found_in_trash' => __('No items found in trash.', 'invoicing') |
|
| 62 | 62 | ), |
| 63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
| 63 | + 'description' => __('This is where you can add new invoice items.', 'invoicing'), |
|
| 64 | 64 | 'public' => false, |
| 65 | 65 | 'has_archive' => false, |
| 66 | 66 | '_builtin' => false, |
| 67 | 67 | 'show_ui' => true, |
| 68 | 68 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
| 69 | 69 | 'show_in_nav_menus' => false, |
| 70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
| 70 | + 'supports' => array('title', 'excerpt', 'thumbnail'), |
|
| 71 | 71 | 'rewrite' => false, |
| 72 | 72 | 'query_var' => false, |
| 73 | 73 | 'map_meta_cap' => true, |
@@ -84,22 +84,22 @@ discard block |
||
| 84 | 84 | 'wpinv_register_post_type_payment_form', |
| 85 | 85 | array( |
| 86 | 86 | 'labels' => array( |
| 87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
| 88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
| 89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
| 90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
| 91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
| 92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
| 93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
| 94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
| 95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
| 96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
| 97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
| 98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
| 99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
| 100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
| 87 | + 'name' => _x('Payment Forms', 'post type general name', 'invoicing'), |
|
| 88 | + 'singular_name' => _x('Payment Form', 'post type singular name', 'invoicing'), |
|
| 89 | + 'menu_name' => _x('Payment Forms', 'admin menu', 'invoicing'), |
|
| 90 | + 'name_admin_bar' => _x('Payment Form', 'add new on admin bar', 'invoicing'), |
|
| 91 | + 'add_new' => _x('Add New', 'Payment Form', 'invoicing'), |
|
| 92 | + 'add_new_item' => __('Add New Payment Form', 'invoicing'), |
|
| 93 | + 'new_item' => __('New Payment Form', 'invoicing'), |
|
| 94 | + 'edit_item' => __('Edit Payment Form', 'invoicing'), |
|
| 95 | + 'view_item' => __('View Payment Form', 'invoicing'), |
|
| 96 | + 'all_items' => __('Payment Forms', 'invoicing'), |
|
| 97 | + 'search_items' => __('Search Payment Forms', 'invoicing'), |
|
| 98 | + 'parent_item_colon' => __('Parent Payment Forms:', 'invoicing'), |
|
| 99 | + 'not_found' => __('No payment forms found.', 'invoicing'), |
|
| 100 | + 'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing') |
|
| 101 | 101 | ), |
| 102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
| 102 | + 'description' => __('Add new payment forms.', 'invoicing'), |
|
| 103 | 103 | 'public' => false, |
| 104 | 104 | 'show_ui' => true, |
| 105 | 105 | 'show_in_menu' => $capabilities ? 'wpinv' : true, |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | 'has_archive' => false, |
| 111 | 111 | 'hierarchical' => false, |
| 112 | 112 | 'menu_position' => null, |
| 113 | - 'supports' => array( 'title' ), |
|
| 113 | + 'supports' => array('title'), |
|
| 114 | 114 | 'menu_icon' => 'dashicons-media-form', |
| 115 | 115 | 'capabilities' => array( |
| 116 | 116 | 'edit_post' => $capabilities, |
@@ -133,32 +133,32 @@ discard block |
||
| 133 | 133 | 'wpinv_register_post_type_invoice', |
| 134 | 134 | array( |
| 135 | 135 | 'labels' => array( |
| 136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
| 137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
| 138 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
| 139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
| 140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
| 141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
| 142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
| 143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
| 144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
| 145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
| 146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
| 147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
| 148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
| 149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
| 150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
| 151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
| 152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
| 153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
| 154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
| 155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
| 156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
| 157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
| 158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
| 159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
| 136 | + 'name' => __('Invoices', 'invoicing'), |
|
| 137 | + 'singular_name' => __('Invoice', 'invoicing'), |
|
| 138 | + 'all_items' => __('Invoices', 'invoicing'), |
|
| 139 | + 'menu_name' => _x('Invoices', 'Admin menu name', 'invoicing'), |
|
| 140 | + 'add_new' => __('Add New', 'invoicing'), |
|
| 141 | + 'add_new_item' => __('Add new invoice', 'invoicing'), |
|
| 142 | + 'edit' => __('Edit', 'invoicing'), |
|
| 143 | + 'edit_item' => __('Edit invoice', 'invoicing'), |
|
| 144 | + 'new_item' => __('New invoice', 'invoicing'), |
|
| 145 | + 'view_item' => __('View invoice', 'invoicing'), |
|
| 146 | + 'view_items' => __('View Invoices', 'invoicing'), |
|
| 147 | + 'search_items' => __('Search invoices', 'invoicing'), |
|
| 148 | + 'not_found' => __('No invoices found', 'invoicing'), |
|
| 149 | + 'not_found_in_trash' => __('No invoices found in trash', 'invoicing'), |
|
| 150 | + 'parent' => __('Parent invoice', 'invoicing'), |
|
| 151 | + 'featured_image' => __('Invoice image', 'invoicing'), |
|
| 152 | + 'set_featured_image' => __('Set invoice image', 'invoicing'), |
|
| 153 | + 'remove_featured_image' => __('Remove invoice image', 'invoicing'), |
|
| 154 | + 'use_featured_image' => __('Use as invoice image', 'invoicing'), |
|
| 155 | + 'insert_into_item' => __('Insert into invoice', 'invoicing'), |
|
| 156 | + 'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'), |
|
| 157 | + 'filter_items_list' => __('Filter invoices', 'invoicing'), |
|
| 158 | + 'items_list_navigation' => __('Invoices navigation', 'invoicing'), |
|
| 159 | + 'items_list' => __('Invoices list', 'invoicing'), |
|
| 160 | 160 | ), |
| 161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
| 161 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
| 162 | 162 | 'public' => true, |
| 163 | 163 | 'has_archive' => false, |
| 164 | 164 | 'publicly_queryable' => true, |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | 'show_ui' => true, |
| 167 | 167 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
| 168 | 168 | 'show_in_nav_menus' => false, |
| 169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
| 169 | + 'supports' => array('title', 'author', 'excerpt'), |
|
| 170 | 170 | 'rewrite' => array( |
| 171 | 171 | 'slug' => 'invoice', |
| 172 | 172 | 'with_front' => false, |
@@ -189,32 +189,32 @@ discard block |
||
| 189 | 189 | 'wpinv_register_post_type_discount', |
| 190 | 190 | array( |
| 191 | 191 | 'labels' => array( |
| 192 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
| 193 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
| 194 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
| 195 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
| 196 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
| 197 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
| 198 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
| 199 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
| 200 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
| 201 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
| 202 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
| 203 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
| 204 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
| 205 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
| 206 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
| 207 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
| 208 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
| 209 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
| 210 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
| 211 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
| 212 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
| 213 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
| 214 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
| 215 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
| 192 | + 'name' => __('Discounts', 'invoicing'), |
|
| 193 | + 'singular_name' => __('Discount', 'invoicing'), |
|
| 194 | + 'all_items' => __('Discounts', 'invoicing'), |
|
| 195 | + 'menu_name' => _x('Discounts', 'Admin menu name', 'invoicing'), |
|
| 196 | + 'add_new' => __('Add New', 'invoicing'), |
|
| 197 | + 'add_new_item' => __('Add new discount', 'invoicing'), |
|
| 198 | + 'edit' => __('Edit', 'invoicing'), |
|
| 199 | + 'edit_item' => __('Edit discount', 'invoicing'), |
|
| 200 | + 'new_item' => __('New discount', 'invoicing'), |
|
| 201 | + 'view_item' => __('View discount', 'invoicing'), |
|
| 202 | + 'view_items' => __('View Discounts', 'invoicing'), |
|
| 203 | + 'search_items' => __('Search discounts', 'invoicing'), |
|
| 204 | + 'not_found' => __('No discounts found', 'invoicing'), |
|
| 205 | + 'not_found_in_trash' => __('No discounts found in trash', 'invoicing'), |
|
| 206 | + 'parent' => __('Parent discount', 'invoicing'), |
|
| 207 | + 'featured_image' => __('Discount image', 'invoicing'), |
|
| 208 | + 'set_featured_image' => __('Set discount image', 'invoicing'), |
|
| 209 | + 'remove_featured_image' => __('Remove discount image', 'invoicing'), |
|
| 210 | + 'use_featured_image' => __('Use as discount image', 'invoicing'), |
|
| 211 | + 'insert_into_item' => __('Insert into discount', 'invoicing'), |
|
| 212 | + 'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'), |
|
| 213 | + 'filter_items_list' => __('Filter discounts', 'invoicing'), |
|
| 214 | + 'items_list_navigation' => __('Discount navigation', 'invoicing'), |
|
| 215 | + 'items_list' => __('Discounts list', 'invoicing'), |
|
| 216 | 216 | ), |
| 217 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
| 217 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
| 218 | 218 | 'public' => false, |
| 219 | 219 | 'can_export' => true, |
| 220 | 220 | '_builtin' => false, |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'map_meta_cap' => true, |
| 228 | 228 | 'has_archive' => false, |
| 229 | 229 | 'hierarchical' => false, |
| 230 | - 'supports' => array( 'title', 'excerpt' ), |
|
| 230 | + 'supports' => array('title', 'excerpt'), |
|
| 231 | 231 | 'show_in_nav_menus' => false, |
| 232 | 232 | 'show_in_admin_bar' => true, |
| 233 | 233 | 'menu_position' => null, |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | ) |
| 236 | 236 | ); |
| 237 | 237 | |
| 238 | - do_action( 'getpaid_after_register_post_types' ); |
|
| 238 | + do_action('getpaid_after_register_post_types'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -248,79 +248,79 @@ discard block |
||
| 248 | 248 | array( |
| 249 | 249 | |
| 250 | 250 | 'wpi-pending' => array( |
| 251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
| 251 | + 'label' => _x('Pending Payment', 'Invoice status', 'invoicing'), |
|
| 252 | 252 | 'public' => true, |
| 253 | 253 | 'exclude_from_search' => true, |
| 254 | 254 | 'show_in_admin_all_list' => true, |
| 255 | 255 | 'show_in_admin_status_list' => true, |
| 256 | 256 | /* translators: %s: number of invoices */ |
| 257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
| 257 | + 'label_count' => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing') |
|
| 258 | 258 | ), |
| 259 | 259 | |
| 260 | 260 | 'wpi-processing' => array( |
| 261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
| 261 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
| 262 | 262 | 'public' => true, |
| 263 | 263 | 'exclude_from_search' => true, |
| 264 | 264 | 'show_in_admin_all_list' => true, |
| 265 | 265 | 'show_in_admin_status_list' => true, |
| 266 | 266 | /* translators: %s: number of invoices */ |
| 267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
| 267 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
| 268 | 268 | ), |
| 269 | 269 | |
| 270 | 270 | 'wpi-onhold' => array( |
| 271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
| 271 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
| 272 | 272 | 'public' => true, |
| 273 | 273 | 'exclude_from_search' => true, |
| 274 | 274 | 'show_in_admin_all_list' => true, |
| 275 | 275 | 'show_in_admin_status_list' => true, |
| 276 | 276 | /* translators: %s: number of invoices */ |
| 277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
| 277 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
| 278 | 278 | ), |
| 279 | 279 | |
| 280 | 280 | 'wpi-cancelled' => array( |
| 281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
| 281 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
| 282 | 282 | 'public' => true, |
| 283 | 283 | 'exclude_from_search' => true, |
| 284 | 284 | 'show_in_admin_all_list' => true, |
| 285 | 285 | 'show_in_admin_status_list' => true, |
| 286 | 286 | /* translators: %s: number of invoices */ |
| 287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
| 287 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
| 288 | 288 | ), |
| 289 | 289 | |
| 290 | 290 | 'wpi-refunded' => array( |
| 291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
| 291 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
| 292 | 292 | 'public' => true, |
| 293 | 293 | 'exclude_from_search' => true, |
| 294 | 294 | 'show_in_admin_all_list' => true, |
| 295 | 295 | 'show_in_admin_status_list' => true, |
| 296 | 296 | /* translators: %s: number of invoices */ |
| 297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
| 297 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
| 298 | 298 | ), |
| 299 | 299 | |
| 300 | 300 | 'wpi-failed' => array( |
| 301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
| 301 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
| 302 | 302 | 'public' => true, |
| 303 | 303 | 'exclude_from_search' => true, |
| 304 | 304 | 'show_in_admin_all_list' => true, |
| 305 | 305 | 'show_in_admin_status_list' => true, |
| 306 | 306 | /* translators: %s: number of invoices */ |
| 307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
| 307 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
| 308 | 308 | ), |
| 309 | 309 | |
| 310 | 310 | 'wpi-renewal' => array( |
| 311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
| 311 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
| 312 | 312 | 'public' => true, |
| 313 | 313 | 'exclude_from_search' => true, |
| 314 | 314 | 'show_in_admin_all_list' => true, |
| 315 | 315 | 'show_in_admin_status_list' => true, |
| 316 | 316 | /* translators: %s: number of invoices */ |
| 317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
| 317 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
| 318 | 318 | ) |
| 319 | 319 | ) |
| 320 | 320 | ); |
| 321 | 321 | |
| 322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
| 323 | - register_post_status( $invoice_statuse, $args ); |
|
| 322 | + foreach ($invoice_statuses as $invoice_statuse => $args) { |
|
| 323 | + register_post_status($invoice_statuse, $args); |
|
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | */ |
| 338 | 338 | public static function maybe_flush_rewrite_rules() { |
| 339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
| 340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
| 339 | + if (!get_option('getpaid_flushed_rewrite_rules')) { |
|
| 340 | + update_option('getpaid_flushed_rewrite_rules', '1'); |
|
| 341 | 341 | self::flush_rewrite_rules(); |
| 342 | 342 | } |
| 343 | 343 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -10,55 +10,55 @@ discard block |
||
| 10 | 10 | class GetPaid_Payment_Form extends GetPaid_Data { |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Which data store to load. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 13 | + * Which data store to load. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | 17 | protected $data_store_name = 'payment_form'; |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * This is the name of this object type. |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $object_type = 'payment_form'; |
|
| 20 | + * This is the name of this object type. |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $object_type = 'payment_form'; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Form Data array. This is the core form data exposed in APIs. |
|
| 28 | - * |
|
| 29 | - * @since 1.0.19 |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - protected $data = array( |
|
| 33 | - 'status' => 'draft', |
|
| 34 | - 'version' => '', |
|
| 35 | - 'date_created' => null, |
|
| 27 | + * Form Data array. This is the core form data exposed in APIs. |
|
| 28 | + * |
|
| 29 | + * @since 1.0.19 |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + protected $data = array( |
|
| 33 | + 'status' => 'draft', |
|
| 34 | + 'version' => '', |
|
| 35 | + 'date_created' => null, |
|
| 36 | 36 | 'date_modified' => null, |
| 37 | 37 | 'name' => '', |
| 38 | 38 | 'author' => 1, |
| 39 | 39 | 'elements' => null, |
| 40 | - 'items' => null, |
|
| 41 | - 'earned' => 0, |
|
| 42 | - 'refunded' => 0, |
|
| 43 | - 'cancelled' => 0, |
|
| 44 | - 'failed' => 0, |
|
| 45 | - ); |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Stores meta in cache for future reads. |
|
| 49 | - * |
|
| 50 | - * A group must be set to to enable caching. |
|
| 51 | - * |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - protected $cache_group = 'getpaid_forms'; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Stores a reference to the invoice if the form is for an invoice.. |
|
| 58 | - * |
|
| 59 | - * @var WPInv_Invoice |
|
| 60 | - */ |
|
| 61 | - public $invoice = 0; |
|
| 40 | + 'items' => null, |
|
| 41 | + 'earned' => 0, |
|
| 42 | + 'refunded' => 0, |
|
| 43 | + 'cancelled' => 0, |
|
| 44 | + 'failed' => 0, |
|
| 45 | + ); |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Stores meta in cache for future reads. |
|
| 49 | + * |
|
| 50 | + * A group must be set to to enable caching. |
|
| 51 | + * |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + protected $cache_group = 'getpaid_forms'; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Stores a reference to the invoice if the form is for an invoice.. |
|
| 58 | + * |
|
| 59 | + * @var WPInv_Invoice |
|
| 60 | + */ |
|
| 61 | + public $invoice = 0; |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Stores a reference to the original WP_Post object |
@@ -68,35 +68,35 @@ discard block |
||
| 68 | 68 | protected $post = null; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Get the form if ID is passed, otherwise the form is new and empty. |
|
| 72 | - * |
|
| 73 | - * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
| 74 | - */ |
|
| 75 | - public function __construct( $form = 0 ) { |
|
| 76 | - parent::__construct( $form ); |
|
| 71 | + * Get the form if ID is passed, otherwise the form is new and empty. |
|
| 72 | + * |
|
| 73 | + * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
| 74 | + */ |
|
| 75 | + public function __construct( $form = 0 ) { |
|
| 76 | + parent::__construct( $form ); |
|
| 77 | 77 | |
| 78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
| 79 | - $this->set_id( $form ); |
|
| 80 | - } elseif ( $form instanceof self ) { |
|
| 78 | + if ( is_numeric( $form ) && $form > 0 ) { |
|
| 79 | + $this->set_id( $form ); |
|
| 80 | + } elseif ( $form instanceof self ) { |
|
| 81 | 81 | |
| 82 | - $this->set_id( $form->get_id() ); |
|
| 83 | - $this->invoice = $form->invoice; |
|
| 82 | + $this->set_id( $form->get_id() ); |
|
| 83 | + $this->invoice = $form->invoice; |
|
| 84 | 84 | |
| 85 | - } elseif ( ! empty( $form->ID ) ) { |
|
| 86 | - $this->set_id( $form->ID ); |
|
| 87 | - } else { |
|
| 88 | - $this->set_object_read( true ); |
|
| 89 | - } |
|
| 85 | + } elseif ( ! empty( $form->ID ) ) { |
|
| 86 | + $this->set_id( $form->ID ); |
|
| 87 | + } else { |
|
| 88 | + $this->set_object_read( true ); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | // Load the datastore. |
| 92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 92 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 93 | 93 | |
| 94 | - if ( $this->get_id() > 0 ) { |
|
| 94 | + if ( $this->get_id() > 0 ) { |
|
| 95 | 95 | $this->post = get_post( $this->get_id() ); |
| 96 | - $this->data_store->read( $this ); |
|
| 96 | + $this->data_store->read( $this ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | /* |
| 102 | 102 | |-------------------------------------------------------------------------- |
@@ -114,358 +114,358 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | - * Get plugin version when the form was created. |
|
| 118 | - * |
|
| 119 | - * @since 1.0.19 |
|
| 120 | - * @param string $context View or edit context. |
|
| 121 | - * @return string |
|
| 122 | - */ |
|
| 123 | - public function get_version( $context = 'view' ) { |
|
| 124 | - return $this->get_prop( 'version', $context ); |
|
| 117 | + * Get plugin version when the form was created. |
|
| 118 | + * |
|
| 119 | + * @since 1.0.19 |
|
| 120 | + * @param string $context View or edit context. |
|
| 121 | + * @return string |
|
| 122 | + */ |
|
| 123 | + public function get_version( $context = 'view' ) { |
|
| 124 | + return $this->get_prop( 'version', $context ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * Get date when the form was created. |
|
| 129 | - * |
|
| 130 | - * @since 1.0.19 |
|
| 131 | - * @param string $context View or edit context. |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public function get_date_created( $context = 'view' ) { |
|
| 135 | - return $this->get_prop( 'date_created', $context ); |
|
| 128 | + * Get date when the form was created. |
|
| 129 | + * |
|
| 130 | + * @since 1.0.19 |
|
| 131 | + * @param string $context View or edit context. |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public function get_date_created( $context = 'view' ) { |
|
| 135 | + return $this->get_prop( 'date_created', $context ); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | - * Get GMT date when the form was created. |
|
| 140 | - * |
|
| 141 | - * @since 1.0.19 |
|
| 142 | - * @param string $context View or edit context. |
|
| 143 | - * @return string |
|
| 144 | - */ |
|
| 145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 139 | + * Get GMT date when the form was created. |
|
| 140 | + * |
|
| 141 | + * @since 1.0.19 |
|
| 142 | + * @param string $context View or edit context. |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 145 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 146 | 146 | $date = $this->get_date_created( $context ); |
| 147 | 147 | |
| 148 | 148 | if ( $date ) { |
| 149 | 149 | $date = get_gmt_from_date( $date ); |
| 150 | 150 | } |
| 151 | - return $date; |
|
| 151 | + return $date; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | - * Get date when the form was last modified. |
|
| 156 | - * |
|
| 157 | - * @since 1.0.19 |
|
| 158 | - * @param string $context View or edit context. |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function get_date_modified( $context = 'view' ) { |
|
| 162 | - return $this->get_prop( 'date_modified', $context ); |
|
| 155 | + * Get date when the form was last modified. |
|
| 156 | + * |
|
| 157 | + * @since 1.0.19 |
|
| 158 | + * @param string $context View or edit context. |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function get_date_modified( $context = 'view' ) { |
|
| 162 | + return $this->get_prop( 'date_modified', $context ); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | - * Get GMT date when the form was last modified. |
|
| 167 | - * |
|
| 168 | - * @since 1.0.19 |
|
| 169 | - * @param string $context View or edit context. |
|
| 170 | - * @return string |
|
| 171 | - */ |
|
| 172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 166 | + * Get GMT date when the form was last modified. |
|
| 167 | + * |
|
| 168 | + * @since 1.0.19 |
|
| 169 | + * @param string $context View or edit context. |
|
| 170 | + * @return string |
|
| 171 | + */ |
|
| 172 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 173 | 173 | $date = $this->get_date_modified( $context ); |
| 174 | 174 | |
| 175 | 175 | if ( $date ) { |
| 176 | 176 | $date = get_gmt_from_date( $date ); |
| 177 | 177 | } |
| 178 | - return $date; |
|
| 178 | + return $date; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | - * Get the form name. |
|
| 183 | - * |
|
| 184 | - * @since 1.0.19 |
|
| 185 | - * @param string $context View or edit context. |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 188 | - public function get_name( $context = 'view' ) { |
|
| 189 | - return $this->get_prop( 'name', $context ); |
|
| 182 | + * Get the form name. |
|
| 183 | + * |
|
| 184 | + * @since 1.0.19 |
|
| 185 | + * @param string $context View or edit context. |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | + public function get_name( $context = 'view' ) { |
|
| 189 | + return $this->get_prop( 'name', $context ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | - * Alias of self::get_name(). |
|
| 194 | - * |
|
| 195 | - * @since 1.0.19 |
|
| 196 | - * @param string $context View or edit context. |
|
| 197 | - * @return string |
|
| 198 | - */ |
|
| 199 | - public function get_title( $context = 'view' ) { |
|
| 200 | - return $this->get_name( $context ); |
|
| 201 | - } |
|
| 193 | + * Alias of self::get_name(). |
|
| 194 | + * |
|
| 195 | + * @since 1.0.19 |
|
| 196 | + * @param string $context View or edit context. |
|
| 197 | + * @return string |
|
| 198 | + */ |
|
| 199 | + public function get_title( $context = 'view' ) { |
|
| 200 | + return $this->get_name( $context ); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * Get the owner of the form. |
|
| 205 | - * |
|
| 206 | - * @since 1.0.19 |
|
| 207 | - * @param string $context View or edit context. |
|
| 208 | - * @return int |
|
| 209 | - */ |
|
| 210 | - public function get_author( $context = 'view' ) { |
|
| 211 | - return (int) $this->get_prop( 'author', $context ); |
|
| 204 | + * Get the owner of the form. |
|
| 205 | + * |
|
| 206 | + * @since 1.0.19 |
|
| 207 | + * @param string $context View or edit context. |
|
| 208 | + * @return int |
|
| 209 | + */ |
|
| 210 | + public function get_author( $context = 'view' ) { |
|
| 211 | + return (int) $this->get_prop( 'author', $context ); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * Get the elements that make up the form. |
|
| 216 | - * |
|
| 217 | - * @since 1.0.19 |
|
| 218 | - * @param string $context View or edit context. |
|
| 219 | - * @return array |
|
| 220 | - */ |
|
| 221 | - public function get_elements( $context = 'view' ) { |
|
| 222 | - $elements = $this->get_prop( 'elements', $context ); |
|
| 215 | + * Get the elements that make up the form. |
|
| 216 | + * |
|
| 217 | + * @since 1.0.19 |
|
| 218 | + * @param string $context View or edit context. |
|
| 219 | + * @return array |
|
| 220 | + */ |
|
| 221 | + public function get_elements( $context = 'view' ) { |
|
| 222 | + $elements = $this->get_prop( 'elements', $context ); |
|
| 223 | 223 | |
| 224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
| 224 | + if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
| 225 | 225 | return wpinv_get_data( 'sample-payment-form' ); |
| 226 | - } |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - // Ensure that all required elements exist. |
|
| 229 | - $_elements = array(); |
|
| 230 | - foreach ( $elements as $element ) { |
|
| 228 | + // Ensure that all required elements exist. |
|
| 229 | + $_elements = array(); |
|
| 230 | + foreach ( $elements as $element ) { |
|
| 231 | 231 | |
| 232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
| 232 | + if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
| 233 | 233 | |
| 234 | - $_elements[] = array( |
|
| 235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 236 | - 'id' => 'gtscicd', |
|
| 237 | - 'name' => 'gtscicd', |
|
| 238 | - 'type' => 'gateway_select', |
|
| 239 | - 'premade' => true |
|
| 234 | + $_elements[] = array( |
|
| 235 | + 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 236 | + 'id' => 'gtscicd', |
|
| 237 | + 'name' => 'gtscicd', |
|
| 238 | + 'type' => 'gateway_select', |
|
| 239 | + 'premade' => true |
|
| 240 | 240 | |
| 241 | - ); |
|
| 241 | + ); |
|
| 242 | 242 | |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - $_elements[] = $element; |
|
| 245 | + $_elements[] = $element; |
|
| 246 | 246 | |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | 249 | return $_elements; |
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Get the items sold via the form. |
|
| 254 | - * |
|
| 255 | - * @since 1.0.19 |
|
| 256 | - * @param string $context View or edit context. |
|
| 257 | - * @param string $return objects or arrays. |
|
| 258 | - * @return GetPaid_Form_Item[] |
|
| 259 | - */ |
|
| 260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
| 261 | - $items = $this->get_prop( 'items', $context ); |
|
| 262 | - |
|
| 263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Get the items sold via the form. |
|
| 254 | + * |
|
| 255 | + * @since 1.0.19 |
|
| 256 | + * @param string $context View or edit context. |
|
| 257 | + * @param string $return objects or arrays. |
|
| 258 | + * @return GetPaid_Form_Item[] |
|
| 259 | + */ |
|
| 260 | + public function get_items( $context = 'view', $return = 'objects' ) { |
|
| 261 | + $items = $this->get_prop( 'items', $context ); |
|
| 262 | + |
|
| 263 | + if ( empty( $items ) || ! is_array( $items ) ) { |
|
| 264 | 264 | $items = wpinv_get_data( 'sample-payment-form-items' ); |
| 265 | - } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + // Convert the items. |
|
| 268 | + $prepared = array(); |
|
| 269 | + |
|
| 270 | + foreach ( $items as $key => $value ) { |
|
| 271 | + |
|
| 272 | + // Form items. |
|
| 273 | + if ( $value instanceof GetPaid_Form_Item ) { |
|
| 274 | + |
|
| 275 | + if ( $value->can_purchase() ) { |
|
| 276 | + $prepared[] = $value; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + continue; |
|
| 280 | + |
|
| 281 | + } |
|
| 266 | 282 | |
| 267 | - // Convert the items. |
|
| 268 | - $prepared = array(); |
|
| 283 | + // $item_id => $quantity (buy buttons) |
|
| 284 | + if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
| 285 | + $item = new GetPaid_Form_Item( $key ); |
|
| 269 | 286 | |
| 270 | - foreach ( $items as $key => $value ) { |
|
| 287 | + if ( $item->can_purchase() ) { |
|
| 271 | 288 | |
| 272 | - // Form items. |
|
| 273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
| 289 | + $value = (float) $value; |
|
| 290 | + $item->set_quantity( $value ); |
|
| 291 | + if ( 0 == $value ) { |
|
| 292 | + $item->set_quantity( 1 ); |
|
| 293 | + $item->set_allow_quantities( true ); |
|
| 294 | + } |
|
| 274 | 295 | |
| 275 | - if ( $value->can_purchase() ) { |
|
| 276 | - $prepared[] = $value; |
|
| 277 | - } |
|
| 296 | + $prepared[] = $item; |
|
| 297 | + } |
|
| 278 | 298 | |
| 279 | - continue; |
|
| 299 | + continue; |
|
| 300 | + } |
|
| 280 | 301 | |
| 281 | - } |
|
| 302 | + // Items saved via payment forms editor. |
|
| 303 | + if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
| 282 | 304 | |
| 283 | - // $item_id => $quantity (buy buttons) |
|
| 284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
| 285 | - $item = new GetPaid_Form_Item( $key ); |
|
| 305 | + $item = new GetPaid_Form_Item( $value['id'] ); |
|
| 286 | 306 | |
| 287 | - if ( $item->can_purchase() ) { |
|
| 307 | + if ( ! $item->can_purchase() ) { |
|
| 308 | + continue; |
|
| 309 | + } |
|
| 288 | 310 | |
| 289 | - $value = (float) $value; |
|
| 290 | - $item->set_quantity( $value ); |
|
| 291 | - if ( 0 == $value ) { |
|
| 292 | - $item->set_quantity( 1 ); |
|
| 293 | - $item->set_allow_quantities( true ); |
|
| 294 | - } |
|
| 311 | + // Sub-total (Cart items). |
|
| 312 | + if ( isset( $value['subtotal'] ) ) { |
|
| 313 | + $item->set_price( $value['subtotal'] ); |
|
| 314 | + } |
|
| 295 | 315 | |
| 296 | - $prepared[] = $item; |
|
| 297 | - } |
|
| 316 | + if ( isset( $value['quantity'] ) ) { |
|
| 317 | + $item->set_quantity( $value['quantity'] ); |
|
| 318 | + } |
|
| 298 | 319 | |
| 299 | - continue; |
|
| 300 | - } |
|
| 320 | + if ( isset( $value['allow_quantities'] ) ) { |
|
| 321 | + $item->set_allow_quantities( $value['allow_quantities'] ); |
|
| 322 | + } |
|
| 301 | 323 | |
| 302 | - // Items saved via payment forms editor. |
|
| 303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
| 324 | + if ( isset( $value['required'] ) ) { |
|
| 325 | + $item->set_is_required( $value['required'] ); |
|
| 326 | + } |
|
| 304 | 327 | |
| 305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
| 328 | + if ( isset( $value['description'] ) ) { |
|
| 329 | + $item->set_custom_description( $value['description'] ); |
|
| 330 | + } |
|
| 306 | 331 | |
| 307 | - if ( ! $item->can_purchase() ) { |
|
| 308 | - continue; |
|
| 309 | - } |
|
| 332 | + $prepared[] = $item; |
|
| 333 | + continue; |
|
| 310 | 334 | |
| 311 | - // Sub-total (Cart items). |
|
| 312 | - if ( isset( $value['subtotal'] ) ) { |
|
| 313 | - $item->set_price( $value['subtotal'] ); |
|
| 314 | - } |
|
| 335 | + } |
|
| 315 | 336 | |
| 316 | - if ( isset( $value['quantity'] ) ) { |
|
| 317 | - $item->set_quantity( $value['quantity'] ); |
|
| 318 | - } |
|
| 337 | + // $item_id => array( 'price' => 10 ) (item variations) |
|
| 338 | + if ( is_numeric( $key ) && is_array( $value ) ) { |
|
| 339 | + $item = new GetPaid_Form_Item( $key ); |
|
| 319 | 340 | |
| 320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
| 321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
| 322 | - } |
|
| 341 | + if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
| 342 | + $item->set_price( $value['price'] ); |
|
| 343 | + } |
|
| 323 | 344 | |
| 324 | - if ( isset( $value['required'] ) ) { |
|
| 325 | - $item->set_is_required( $value['required'] ); |
|
| 326 | - } |
|
| 345 | + if ( $item->can_purchase() ) { |
|
| 346 | + $prepared[] = $item; |
|
| 347 | + } |
|
| 327 | 348 | |
| 328 | - if ( isset( $value['description'] ) ) { |
|
| 329 | - $item->set_custom_description( $value['description'] ); |
|
| 330 | - } |
|
| 349 | + continue; |
|
| 350 | + } |
|
| 331 | 351 | |
| 332 | - $prepared[] = $item; |
|
| 333 | - continue; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + if ( 'objects' == $return && 'view' == $context ) { |
|
| 355 | + return $prepared; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + $items = array(); |
|
| 359 | + foreach ( $prepared as $item ) { |
|
| 360 | + $items[] = $item->prepare_data_for_use(); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + return $items; |
|
| 364 | + } |
|
| 334 | 365 | |
| 335 | - } |
|
| 366 | + /** |
|
| 367 | + * Get a single item belonging to the form. |
|
| 368 | + * |
|
| 369 | + * @since 1.0.19 |
|
| 370 | + * @param int $item_id The item id to return. |
|
| 371 | + * @return GetPaid_Form_Item|bool |
|
| 372 | + */ |
|
| 373 | + public function get_item( $item_id ) { |
|
| 336 | 374 | |
| 337 | - // $item_id => array( 'price' => 10 ) (item variations) |
|
| 338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
| 339 | - $item = new GetPaid_Form_Item( $key ); |
|
| 375 | + if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
| 376 | + return false; |
|
| 377 | + } |
|
| 340 | 378 | |
| 341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
| 342 | - $item->set_price( $value['price'] ); |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - if ( $item->can_purchase() ) { |
|
| 346 | - $prepared[] = $item; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - continue; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - if ( 'objects' == $return && 'view' == $context ) { |
|
| 355 | - return $prepared; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - $items = array(); |
|
| 359 | - foreach ( $prepared as $item ) { |
|
| 360 | - $items[] = $item->prepare_data_for_use(); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - return $items; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * Get a single item belonging to the form. |
|
| 368 | - * |
|
| 369 | - * @since 1.0.19 |
|
| 370 | - * @param int $item_id The item id to return. |
|
| 371 | - * @return GetPaid_Form_Item|bool |
|
| 372 | - */ |
|
| 373 | - public function get_item( $item_id ) { |
|
| 374 | - |
|
| 375 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
| 376 | - return false; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - foreach( $this->get_items() as $item ) { |
|
| 380 | - if ( $item->get_id() == (int) $item_id ) { |
|
| 381 | - return $item; |
|
| 382 | - } |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - return false; |
|
| 386 | - |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Gets a single element. |
|
| 391 | - * |
|
| 392 | - * @since 1.0.19 |
|
| 393 | - * @param string $element_type The element type to return. |
|
| 394 | - * @return array|bool |
|
| 395 | - */ |
|
| 396 | - public function get_element_type( $element_type ) { |
|
| 397 | - |
|
| 398 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
| 399 | - return false; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
| 403 | - |
|
| 404 | - if ( $element['type'] == $element_type ) { |
|
| 405 | - return $element; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - return false; |
|
| 411 | - |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * Get the total amount earned via this form. |
|
| 416 | - * |
|
| 417 | - * @since 1.0.19 |
|
| 418 | - * @param string $context View or edit context. |
|
| 419 | - * @return float |
|
| 420 | - */ |
|
| 421 | - public function get_earned( $context = 'view' ) { |
|
| 422 | - return $this->get_prop( 'earned', $context ); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * Get the total amount refunded via this form. |
|
| 427 | - * |
|
| 428 | - * @since 1.0.19 |
|
| 429 | - * @param string $context View or edit context. |
|
| 430 | - * @return float |
|
| 431 | - */ |
|
| 432 | - public function get_refunded( $context = 'view' ) { |
|
| 433 | - return $this->get_prop( 'refunded', $context ); |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * Get the total amount cancelled via this form. |
|
| 438 | - * |
|
| 439 | - * @since 1.0.19 |
|
| 440 | - * @param string $context View or edit context. |
|
| 441 | - * @return float |
|
| 442 | - */ |
|
| 443 | - public function get_cancelled( $context = 'view' ) { |
|
| 444 | - return $this->get_prop( 'cancelled', $context ); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * Get the total amount failed via this form. |
|
| 449 | - * |
|
| 450 | - * @since 1.0.19 |
|
| 451 | - * @param string $context View or edit context. |
|
| 452 | - * @return float |
|
| 453 | - */ |
|
| 454 | - public function get_failed( $context = 'view' ) { |
|
| 455 | - return $this->get_prop( 'failed', $context ); |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * Get the currency. |
|
| 460 | - * |
|
| 461 | - * @since 1.0.19 |
|
| 462 | - * @param string $context View or edit context. |
|
| 463 | - * @return string |
|
| 464 | - */ |
|
| 465 | - public function get_currency() { |
|
| 466 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 467 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
| 468 | - } |
|
| 379 | + foreach( $this->get_items() as $item ) { |
|
| 380 | + if ( $item->get_id() == (int) $item_id ) { |
|
| 381 | + return $item; |
|
| 382 | + } |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + return false; |
|
| 386 | + |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Gets a single element. |
|
| 391 | + * |
|
| 392 | + * @since 1.0.19 |
|
| 393 | + * @param string $element_type The element type to return. |
|
| 394 | + * @return array|bool |
|
| 395 | + */ |
|
| 396 | + public function get_element_type( $element_type ) { |
|
| 397 | + |
|
| 398 | + if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
| 399 | + return false; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
| 403 | + |
|
| 404 | + if ( $element['type'] == $element_type ) { |
|
| 405 | + return $element; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + return false; |
|
| 411 | + |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * Get the total amount earned via this form. |
|
| 416 | + * |
|
| 417 | + * @since 1.0.19 |
|
| 418 | + * @param string $context View or edit context. |
|
| 419 | + * @return float |
|
| 420 | + */ |
|
| 421 | + public function get_earned( $context = 'view' ) { |
|
| 422 | + return $this->get_prop( 'earned', $context ); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * Get the total amount refunded via this form. |
|
| 427 | + * |
|
| 428 | + * @since 1.0.19 |
|
| 429 | + * @param string $context View or edit context. |
|
| 430 | + * @return float |
|
| 431 | + */ |
|
| 432 | + public function get_refunded( $context = 'view' ) { |
|
| 433 | + return $this->get_prop( 'refunded', $context ); |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * Get the total amount cancelled via this form. |
|
| 438 | + * |
|
| 439 | + * @since 1.0.19 |
|
| 440 | + * @param string $context View or edit context. |
|
| 441 | + * @return float |
|
| 442 | + */ |
|
| 443 | + public function get_cancelled( $context = 'view' ) { |
|
| 444 | + return $this->get_prop( 'cancelled', $context ); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * Get the total amount failed via this form. |
|
| 449 | + * |
|
| 450 | + * @since 1.0.19 |
|
| 451 | + * @param string $context View or edit context. |
|
| 452 | + * @return float |
|
| 453 | + */ |
|
| 454 | + public function get_failed( $context = 'view' ) { |
|
| 455 | + return $this->get_prop( 'failed', $context ); |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * Get the currency. |
|
| 460 | + * |
|
| 461 | + * @since 1.0.19 |
|
| 462 | + * @param string $context View or edit context. |
|
| 463 | + * @return string |
|
| 464 | + */ |
|
| 465 | + public function get_currency() { |
|
| 466 | + $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 467 | + return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
| 468 | + } |
|
| 469 | 469 | |
| 470 | 470 | /* |
| 471 | 471 | |-------------------------------------------------------------------------- |
@@ -478,22 +478,22 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | - * Set plugin version when the item was created. |
|
| 482 | - * |
|
| 483 | - * @since 1.0.19 |
|
| 484 | - */ |
|
| 485 | - public function set_version( $value ) { |
|
| 486 | - $this->set_prop( 'version', $value ); |
|
| 481 | + * Set plugin version when the item was created. |
|
| 482 | + * |
|
| 483 | + * @since 1.0.19 |
|
| 484 | + */ |
|
| 485 | + public function set_version( $value ) { |
|
| 486 | + $this->set_prop( 'version', $value ); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
| 490 | - * Set date when the item was created. |
|
| 491 | - * |
|
| 492 | - * @since 1.0.19 |
|
| 493 | - * @param string $value Value to set. |
|
| 490 | + * Set date when the item was created. |
|
| 491 | + * |
|
| 492 | + * @since 1.0.19 |
|
| 493 | + * @param string $value Value to set. |
|
| 494 | 494 | * @return bool Whether or not the date was set. |
| 495 | - */ |
|
| 496 | - public function set_date_created( $value ) { |
|
| 495 | + */ |
|
| 496 | + public function set_date_created( $value ) { |
|
| 497 | 497 | $date = strtotime( $value ); |
| 498 | 498 | |
| 499 | 499 | if ( $date ) { |
@@ -506,13 +506,13 @@ discard block |
||
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
| 509 | - * Set date when the item was last modified. |
|
| 510 | - * |
|
| 511 | - * @since 1.0.19 |
|
| 512 | - * @param string $value Value to set. |
|
| 509 | + * Set date when the item was last modified. |
|
| 510 | + * |
|
| 511 | + * @since 1.0.19 |
|
| 512 | + * @param string $value Value to set. |
|
| 513 | 513 | * @return bool Whether or not the date was set. |
| 514 | - */ |
|
| 515 | - public function set_date_modified( $value ) { |
|
| 514 | + */ |
|
| 515 | + public function set_date_modified( $value ) { |
|
| 516 | 516 | $date = strtotime( $value ); |
| 517 | 517 | |
| 518 | 518 | if ( $date ) { |
@@ -525,169 +525,169 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
| 528 | - * Set the item name. |
|
| 529 | - * |
|
| 530 | - * @since 1.0.19 |
|
| 531 | - * @param string $value New name. |
|
| 532 | - */ |
|
| 533 | - public function set_name( $value ) { |
|
| 534 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * Alias of self::set_name(). |
|
| 539 | - * |
|
| 540 | - * @since 1.0.19 |
|
| 541 | - * @param string $value New name. |
|
| 542 | - */ |
|
| 543 | - public function set_title( $value ) { |
|
| 544 | - $this->set_name( $value ); |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * Set the owner of the item. |
|
| 549 | - * |
|
| 550 | - * @since 1.0.19 |
|
| 551 | - * @param int $value New author. |
|
| 552 | - */ |
|
| 553 | - public function set_author( $value ) { |
|
| 554 | - $this->set_prop( 'author', (int) $value ); |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * Set the form elements. |
|
| 559 | - * |
|
| 560 | - * @since 1.0.19 |
|
| 561 | - * @sinve 2.3.4 Array values sanitized. |
|
| 562 | - * @param array $value Form elements. |
|
| 563 | - */ |
|
| 564 | - public function set_elements( $value ) { |
|
| 565 | - if ( is_array( $value ) ) { |
|
| 566 | - |
|
| 567 | - // sanitize |
|
| 568 | - $value = $this->sanitize_array_values( $value ); |
|
| 569 | - |
|
| 570 | - $this->set_prop( 'elements', $value ); |
|
| 571 | - } |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * Sanitize array values. |
|
| 576 | - * |
|
| 577 | - * @param $value |
|
| 578 | - * |
|
| 579 | - * @return mixed |
|
| 580 | - */ |
|
| 581 | - public function sanitize_array_values($value){ |
|
| 582 | - |
|
| 583 | - // sanitize |
|
| 584 | - if(!empty($value )){ |
|
| 585 | - |
|
| 586 | - foreach($value as $key => $val_arr){ |
|
| 587 | - |
|
| 588 | - if(is_array($val_arr)){ |
|
| 589 | - // check if we have sub array items. |
|
| 590 | - $sub_arr = array(); |
|
| 591 | - foreach($val_arr as $key2 => $val2){ |
|
| 592 | - if(is_array($val2)){ |
|
| 593 | - $sub_arr[$key2] = $this->sanitize_array_values($val2); |
|
| 594 | - unset($val_arr[$key][$key2]); |
|
| 595 | - } |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - // we allow some html in description so we sanitize it separately. |
|
| 599 | - $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
|
| 600 | - |
|
| 601 | - // sanitize array elements |
|
| 602 | - $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
| 603 | - |
|
| 604 | - // add back the description if set |
|
| 605 | - if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
| 606 | - |
|
| 607 | - // add back sub array items after its been sanitized. |
|
| 608 | - if ( ! empty( $sub_arr ) ) { |
|
| 609 | - $value[$key] = array_merge($value[$key],$sub_arr); |
|
| 610 | - } |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - return $value; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * Set the form items. |
|
| 622 | - * |
|
| 623 | - * @since 1.0.19 |
|
| 624 | - * @param array $value Form elements. |
|
| 625 | - */ |
|
| 626 | - public function set_items( $value ) { |
|
| 627 | - if ( is_array( $value ) ) { |
|
| 628 | - $this->set_prop( 'items', $value ); |
|
| 629 | - } |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - /** |
|
| 633 | - * Set the total amount earned via this form. |
|
| 634 | - * |
|
| 635 | - * @since 1.0.19 |
|
| 636 | - * @param float $value Amount earned. |
|
| 637 | - */ |
|
| 638 | - public function set_earned( $value ) { |
|
| 639 | - $value = max( (float) $value, 0 ); |
|
| 640 | - $this->set_prop( 'earned', $value ); |
|
| 641 | - } |
|
| 642 | - |
|
| 643 | - /** |
|
| 644 | - * Set the total amount refunded via this form. |
|
| 645 | - * |
|
| 646 | - * @since 1.0.19 |
|
| 647 | - * @param float $value Amount refunded. |
|
| 648 | - */ |
|
| 649 | - public function set_refunded( $value ) { |
|
| 650 | - $value = max( (float) $value, 0 ); |
|
| 651 | - $this->set_prop( 'refunded', $value ); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - /** |
|
| 655 | - * Set the total amount cancelled via this form. |
|
| 656 | - * |
|
| 657 | - * @since 1.0.19 |
|
| 658 | - * @param float $value Amount cancelled. |
|
| 659 | - */ |
|
| 660 | - public function set_cancelled( $value ) { |
|
| 661 | - $value = max( (float) $value, 0 ); |
|
| 662 | - $this->set_prop( 'cancelled', $value ); |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * Set the total amount failed via this form. |
|
| 667 | - * |
|
| 668 | - * @since 1.0.19 |
|
| 669 | - * @param float $value Amount cancelled. |
|
| 670 | - */ |
|
| 671 | - public function set_failed( $value ) { |
|
| 672 | - $value = max( (float) $value, 0 ); |
|
| 673 | - $this->set_prop( 'failed', $value ); |
|
| 674 | - } |
|
| 528 | + * Set the item name. |
|
| 529 | + * |
|
| 530 | + * @since 1.0.19 |
|
| 531 | + * @param string $value New name. |
|
| 532 | + */ |
|
| 533 | + public function set_name( $value ) { |
|
| 534 | + $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * Alias of self::set_name(). |
|
| 539 | + * |
|
| 540 | + * @since 1.0.19 |
|
| 541 | + * @param string $value New name. |
|
| 542 | + */ |
|
| 543 | + public function set_title( $value ) { |
|
| 544 | + $this->set_name( $value ); |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * Set the owner of the item. |
|
| 549 | + * |
|
| 550 | + * @since 1.0.19 |
|
| 551 | + * @param int $value New author. |
|
| 552 | + */ |
|
| 553 | + public function set_author( $value ) { |
|
| 554 | + $this->set_prop( 'author', (int) $value ); |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * Set the form elements. |
|
| 559 | + * |
|
| 560 | + * @since 1.0.19 |
|
| 561 | + * @sinve 2.3.4 Array values sanitized. |
|
| 562 | + * @param array $value Form elements. |
|
| 563 | + */ |
|
| 564 | + public function set_elements( $value ) { |
|
| 565 | + if ( is_array( $value ) ) { |
|
| 566 | + |
|
| 567 | + // sanitize |
|
| 568 | + $value = $this->sanitize_array_values( $value ); |
|
| 569 | + |
|
| 570 | + $this->set_prop( 'elements', $value ); |
|
| 571 | + } |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * Sanitize array values. |
|
| 576 | + * |
|
| 577 | + * @param $value |
|
| 578 | + * |
|
| 579 | + * @return mixed |
|
| 580 | + */ |
|
| 581 | + public function sanitize_array_values($value){ |
|
| 582 | + |
|
| 583 | + // sanitize |
|
| 584 | + if(!empty($value )){ |
|
| 585 | + |
|
| 586 | + foreach($value as $key => $val_arr){ |
|
| 587 | + |
|
| 588 | + if(is_array($val_arr)){ |
|
| 589 | + // check if we have sub array items. |
|
| 590 | + $sub_arr = array(); |
|
| 591 | + foreach($val_arr as $key2 => $val2){ |
|
| 592 | + if(is_array($val2)){ |
|
| 593 | + $sub_arr[$key2] = $this->sanitize_array_values($val2); |
|
| 594 | + unset($val_arr[$key][$key2]); |
|
| 595 | + } |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + // we allow some html in description so we sanitize it separately. |
|
| 599 | + $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
|
| 600 | + |
|
| 601 | + // sanitize array elements |
|
| 602 | + $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
| 603 | + |
|
| 604 | + // add back the description if set |
|
| 605 | + if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
| 606 | + |
|
| 607 | + // add back sub array items after its been sanitized. |
|
| 608 | + if ( ! empty( $sub_arr ) ) { |
|
| 609 | + $value[$key] = array_merge($value[$key],$sub_arr); |
|
| 610 | + } |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + return $value; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * Set the form items. |
|
| 622 | + * |
|
| 623 | + * @since 1.0.19 |
|
| 624 | + * @param array $value Form elements. |
|
| 625 | + */ |
|
| 626 | + public function set_items( $value ) { |
|
| 627 | + if ( is_array( $value ) ) { |
|
| 628 | + $this->set_prop( 'items', $value ); |
|
| 629 | + } |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + /** |
|
| 633 | + * Set the total amount earned via this form. |
|
| 634 | + * |
|
| 635 | + * @since 1.0.19 |
|
| 636 | + * @param float $value Amount earned. |
|
| 637 | + */ |
|
| 638 | + public function set_earned( $value ) { |
|
| 639 | + $value = max( (float) $value, 0 ); |
|
| 640 | + $this->set_prop( 'earned', $value ); |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + /** |
|
| 644 | + * Set the total amount refunded via this form. |
|
| 645 | + * |
|
| 646 | + * @since 1.0.19 |
|
| 647 | + * @param float $value Amount refunded. |
|
| 648 | + */ |
|
| 649 | + public function set_refunded( $value ) { |
|
| 650 | + $value = max( (float) $value, 0 ); |
|
| 651 | + $this->set_prop( 'refunded', $value ); |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + /** |
|
| 655 | + * Set the total amount cancelled via this form. |
|
| 656 | + * |
|
| 657 | + * @since 1.0.19 |
|
| 658 | + * @param float $value Amount cancelled. |
|
| 659 | + */ |
|
| 660 | + public function set_cancelled( $value ) { |
|
| 661 | + $value = max( (float) $value, 0 ); |
|
| 662 | + $this->set_prop( 'cancelled', $value ); |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * Set the total amount failed via this form. |
|
| 667 | + * |
|
| 668 | + * @since 1.0.19 |
|
| 669 | + * @param float $value Amount cancelled. |
|
| 670 | + */ |
|
| 671 | + public function set_failed( $value ) { |
|
| 672 | + $value = max( (float) $value, 0 ); |
|
| 673 | + $this->set_prop( 'failed', $value ); |
|
| 674 | + } |
|
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | 677 | * Create an item. For backwards compatibilty. |
| 678 | 678 | * |
| 679 | 679 | * @deprecated |
| 680 | - * @return int item id |
|
| 680 | + * @return int item id |
|
| 681 | 681 | */ |
| 682 | 682 | public function create( $data = array() ) { |
| 683 | 683 | |
| 684 | - // Set the properties. |
|
| 685 | - if ( is_array( $data ) ) { |
|
| 686 | - $this->set_props( $data ); |
|
| 687 | - } |
|
| 684 | + // Set the properties. |
|
| 685 | + if ( is_array( $data ) ) { |
|
| 686 | + $this->set_props( $data ); |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | - // Save the item. |
|
| 690 | - return $this->save(); |
|
| 689 | + // Save the item. |
|
| 690 | + return $this->save(); |
|
| 691 | 691 | |
| 692 | 692 | } |
| 693 | 693 | |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | * Updates an item. For backwards compatibilty. |
| 696 | 696 | * |
| 697 | 697 | * @deprecated |
| 698 | - * @return int item id |
|
| 698 | + * @return int item id |
|
| 699 | 699 | */ |
| 700 | 700 | public function update( $data = array() ) { |
| 701 | 701 | return $this->create( $data ); |
@@ -711,22 +711,22 @@ discard block |
||
| 711 | 711 | */ |
| 712 | 712 | |
| 713 | 713 | /** |
| 714 | - * Checks whether this is the default payment form. |
|
| 715 | - * |
|
| 716 | - * @since 1.0.19 |
|
| 717 | - * @return bool |
|
| 718 | - */ |
|
| 714 | + * Checks whether this is the default payment form. |
|
| 715 | + * |
|
| 716 | + * @since 1.0.19 |
|
| 717 | + * @return bool |
|
| 718 | + */ |
|
| 719 | 719 | public function is_default() { |
| 720 | 720 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
| 721 | 721 | return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
| 722 | - } |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | 724 | /** |
| 725 | - * Checks whether the form is active. |
|
| 726 | - * |
|
| 727 | - * @since 1.0.19 |
|
| 728 | - * @return bool |
|
| 729 | - */ |
|
| 725 | + * Checks whether the form is active. |
|
| 726 | + * |
|
| 727 | + * @since 1.0.19 |
|
| 728 | + * @return bool |
|
| 729 | + */ |
|
| 730 | 730 | public function is_active() { |
| 731 | 731 | $is_active = 0 !== (int) $this->get_id(); |
| 732 | 732 | |
@@ -735,76 +735,76 @@ discard block |
||
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
| 738 | - } |
|
| 739 | - |
|
| 740 | - /** |
|
| 741 | - * Checks whether the form has a given item. |
|
| 742 | - * |
|
| 743 | - * @since 1.0.19 |
|
| 744 | - * @return bool |
|
| 745 | - */ |
|
| 738 | + } |
|
| 739 | + |
|
| 740 | + /** |
|
| 741 | + * Checks whether the form has a given item. |
|
| 742 | + * |
|
| 743 | + * @since 1.0.19 |
|
| 744 | + * @return bool |
|
| 745 | + */ |
|
| 746 | 746 | public function has_item( $item_id ) { |
| 747 | 747 | return false !== $this->get_item( $item_id ); |
| 748 | - } |
|
| 749 | - |
|
| 750 | - /** |
|
| 751 | - * Checks whether the form has a given element. |
|
| 752 | - * |
|
| 753 | - * @since 1.0.19 |
|
| 754 | - * @return bool |
|
| 755 | - */ |
|
| 748 | + } |
|
| 749 | + |
|
| 750 | + /** |
|
| 751 | + * Checks whether the form has a given element. |
|
| 752 | + * |
|
| 753 | + * @since 1.0.19 |
|
| 754 | + * @return bool |
|
| 755 | + */ |
|
| 756 | 756 | public function has_element_type( $element_type ) { |
| 757 | 757 | return false !== $this->get_element_type( $element_type ); |
| 758 | - } |
|
| 759 | - |
|
| 760 | - /** |
|
| 761 | - * Checks whether this form is recurring or not. |
|
| 762 | - * |
|
| 763 | - * @since 1.0.19 |
|
| 764 | - * @return bool |
|
| 765 | - */ |
|
| 758 | + } |
|
| 759 | + |
|
| 760 | + /** |
|
| 761 | + * Checks whether this form is recurring or not. |
|
| 762 | + * |
|
| 763 | + * @since 1.0.19 |
|
| 764 | + * @return bool |
|
| 765 | + */ |
|
| 766 | 766 | public function is_recurring() { |
| 767 | 767 | |
| 768 | - if ( ! empty( $this->invoice ) ) { |
|
| 769 | - return $this->invoice->is_recurring(); |
|
| 770 | - } |
|
| 768 | + if ( ! empty( $this->invoice ) ) { |
|
| 769 | + return $this->invoice->is_recurring(); |
|
| 770 | + } |
|
| 771 | 771 | |
| 772 | - foreach ( $this->get_items() as $item ) { |
|
| 772 | + foreach ( $this->get_items() as $item ) { |
|
| 773 | 773 | |
| 774 | - if ( $item->is_recurring() ) { |
|
| 775 | - return true; |
|
| 776 | - } |
|
| 774 | + if ( $item->is_recurring() ) { |
|
| 775 | + return true; |
|
| 776 | + } |
|
| 777 | 777 | |
| 778 | - } |
|
| 778 | + } |
|
| 779 | 779 | |
| 780 | 780 | return false; |
| 781 | - } |
|
| 781 | + } |
|
| 782 | 782 | |
| 783 | - /** |
|
| 784 | - * Retrieves the form's html. |
|
| 785 | - * |
|
| 786 | - * @since 1.0.19 |
|
| 787 | - */ |
|
| 783 | + /** |
|
| 784 | + * Retrieves the form's html. |
|
| 785 | + * |
|
| 786 | + * @since 1.0.19 |
|
| 787 | + */ |
|
| 788 | 788 | public function get_html( $extra_markup = '' ) { |
| 789 | 789 | |
| 790 | - // Return the HTML. |
|
| 791 | - return wpinv_get_template_html( |
|
| 792 | - 'payment-forms/form.php', |
|
| 793 | - array( |
|
| 794 | - 'form' => $this, |
|
| 795 | - 'extra_markup' => $extra_markup, |
|
| 796 | - ) |
|
| 797 | - ); |
|
| 798 | - |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - /** |
|
| 802 | - * Displays the payment form. |
|
| 803 | - * |
|
| 804 | - * @since 1.0.19 |
|
| 805 | - */ |
|
| 790 | + // Return the HTML. |
|
| 791 | + return wpinv_get_template_html( |
|
| 792 | + 'payment-forms/form.php', |
|
| 793 | + array( |
|
| 794 | + 'form' => $this, |
|
| 795 | + 'extra_markup' => $extra_markup, |
|
| 796 | + ) |
|
| 797 | + ); |
|
| 798 | + |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + /** |
|
| 802 | + * Displays the payment form. |
|
| 803 | + * |
|
| 804 | + * @since 1.0.19 |
|
| 805 | + */ |
|
| 806 | 806 | public function display( $extra_markup = '' ) { |
| 807 | - echo $this->get_html( $extra_markup ); |
|
| 807 | + echo $this->get_html( $extra_markup ); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
| 74 | 74 | */ |
| 75 | - public function __construct( $form = 0 ) { |
|
| 76 | - parent::__construct( $form ); |
|
| 75 | + public function __construct($form = 0) { |
|
| 76 | + parent::__construct($form); |
|
| 77 | 77 | |
| 78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
| 79 | - $this->set_id( $form ); |
|
| 80 | - } elseif ( $form instanceof self ) { |
|
| 78 | + if (is_numeric($form) && $form > 0) { |
|
| 79 | + $this->set_id($form); |
|
| 80 | + } elseif ($form instanceof self) { |
|
| 81 | 81 | |
| 82 | - $this->set_id( $form->get_id() ); |
|
| 82 | + $this->set_id($form->get_id()); |
|
| 83 | 83 | $this->invoice = $form->invoice; |
| 84 | 84 | |
| 85 | - } elseif ( ! empty( $form->ID ) ) { |
|
| 86 | - $this->set_id( $form->ID ); |
|
| 85 | + } elseif (!empty($form->ID)) { |
|
| 86 | + $this->set_id($form->ID); |
|
| 87 | 87 | } else { |
| 88 | - $this->set_object_read( true ); |
|
| 88 | + $this->set_object_read(true); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Load the datastore. |
| 92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 93 | 93 | |
| 94 | - if ( $this->get_id() > 0 ) { |
|
| 95 | - $this->post = get_post( $this->get_id() ); |
|
| 96 | - $this->data_store->read( $this ); |
|
| 94 | + if ($this->get_id() > 0) { |
|
| 95 | + $this->post = get_post($this->get_id()); |
|
| 96 | + $this->data_store->read($this); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | * @param string $context View or edit context. |
| 121 | 121 | * @return string |
| 122 | 122 | */ |
| 123 | - public function get_version( $context = 'view' ) { |
|
| 124 | - return $this->get_prop( 'version', $context ); |
|
| 123 | + public function get_version($context = 'view') { |
|
| 124 | + return $this->get_prop('version', $context); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @param string $context View or edit context. |
| 132 | 132 | * @return string |
| 133 | 133 | */ |
| 134 | - public function get_date_created( $context = 'view' ) { |
|
| 135 | - return $this->get_prop( 'date_created', $context ); |
|
| 134 | + public function get_date_created($context = 'view') { |
|
| 135 | + return $this->get_prop('date_created', $context); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | * @param string $context View or edit context. |
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 146 | - $date = $this->get_date_created( $context ); |
|
| 145 | + public function get_date_created_gmt($context = 'view') { |
|
| 146 | + $date = $this->get_date_created($context); |
|
| 147 | 147 | |
| 148 | - if ( $date ) { |
|
| 149 | - $date = get_gmt_from_date( $date ); |
|
| 148 | + if ($date) { |
|
| 149 | + $date = get_gmt_from_date($date); |
|
| 150 | 150 | } |
| 151 | 151 | return $date; |
| 152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @param string $context View or edit context. |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - public function get_date_modified( $context = 'view' ) { |
|
| 162 | - return $this->get_prop( 'date_modified', $context ); |
|
| 161 | + public function get_date_modified($context = 'view') { |
|
| 162 | + return $this->get_prop('date_modified', $context); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | * @param string $context View or edit context. |
| 170 | 170 | * @return string |
| 171 | 171 | */ |
| 172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 173 | - $date = $this->get_date_modified( $context ); |
|
| 172 | + public function get_date_modified_gmt($context = 'view') { |
|
| 173 | + $date = $this->get_date_modified($context); |
|
| 174 | 174 | |
| 175 | - if ( $date ) { |
|
| 176 | - $date = get_gmt_from_date( $date ); |
|
| 175 | + if ($date) { |
|
| 176 | + $date = get_gmt_from_date($date); |
|
| 177 | 177 | } |
| 178 | 178 | return $date; |
| 179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | * @param string $context View or edit context. |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - public function get_name( $context = 'view' ) { |
|
| 189 | - return $this->get_prop( 'name', $context ); |
|
| 188 | + public function get_name($context = 'view') { |
|
| 189 | + return $this->get_prop('name', $context); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | * @param string $context View or edit context. |
| 197 | 197 | * @return string |
| 198 | 198 | */ |
| 199 | - public function get_title( $context = 'view' ) { |
|
| 200 | - return $this->get_name( $context ); |
|
| 199 | + public function get_title($context = 'view') { |
|
| 200 | + return $this->get_name($context); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | * @param string $context View or edit context. |
| 208 | 208 | * @return int |
| 209 | 209 | */ |
| 210 | - public function get_author( $context = 'view' ) { |
|
| 211 | - return (int) $this->get_prop( 'author', $context ); |
|
| 210 | + public function get_author($context = 'view') { |
|
| 211 | + return (int) $this->get_prop('author', $context); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
| 218 | 218 | * @param string $context View or edit context. |
| 219 | 219 | * @return array |
| 220 | 220 | */ |
| 221 | - public function get_elements( $context = 'view' ) { |
|
| 222 | - $elements = $this->get_prop( 'elements', $context ); |
|
| 221 | + public function get_elements($context = 'view') { |
|
| 222 | + $elements = $this->get_prop('elements', $context); |
|
| 223 | 223 | |
| 224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
| 225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
| 224 | + if (empty($elements) || !is_array($elements)) { |
|
| 225 | + return wpinv_get_data('sample-payment-form'); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Ensure that all required elements exist. |
| 229 | 229 | $_elements = array(); |
| 230 | - foreach ( $elements as $element ) { |
|
| 230 | + foreach ($elements as $element) { |
|
| 231 | 231 | |
| 232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
| 232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
| 233 | 233 | |
| 234 | 234 | $_elements[] = array( |
| 235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
| 236 | 236 | 'id' => 'gtscicd', |
| 237 | 237 | 'name' => 'gtscicd', |
| 238 | 238 | 'type' => 'gateway_select', |
@@ -257,22 +257,22 @@ discard block |
||
| 257 | 257 | * @param string $return objects or arrays. |
| 258 | 258 | * @return GetPaid_Form_Item[] |
| 259 | 259 | */ |
| 260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
| 261 | - $items = $this->get_prop( 'items', $context ); |
|
| 260 | + public function get_items($context = 'view', $return = 'objects') { |
|
| 261 | + $items = $this->get_prop('items', $context); |
|
| 262 | 262 | |
| 263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
| 264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
| 263 | + if (empty($items) || !is_array($items)) { |
|
| 264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Convert the items. |
| 268 | 268 | $prepared = array(); |
| 269 | 269 | |
| 270 | - foreach ( $items as $key => $value ) { |
|
| 270 | + foreach ($items as $key => $value) { |
|
| 271 | 271 | |
| 272 | 272 | // Form items. |
| 273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
| 273 | + if ($value instanceof GetPaid_Form_Item) { |
|
| 274 | 274 | |
| 275 | - if ( $value->can_purchase() ) { |
|
| 275 | + if ($value->can_purchase()) { |
|
| 276 | 276 | $prepared[] = $value; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -281,16 +281,16 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // $item_id => $quantity (buy buttons) |
| 284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
| 285 | - $item = new GetPaid_Form_Item( $key ); |
|
| 284 | + if (is_numeric($key) && is_numeric($value)) { |
|
| 285 | + $item = new GetPaid_Form_Item($key); |
|
| 286 | 286 | |
| 287 | - if ( $item->can_purchase() ) { |
|
| 287 | + if ($item->can_purchase()) { |
|
| 288 | 288 | |
| 289 | 289 | $value = (float) $value; |
| 290 | - $item->set_quantity( $value ); |
|
| 291 | - if ( 0 == $value ) { |
|
| 292 | - $item->set_quantity( 1 ); |
|
| 293 | - $item->set_allow_quantities( true ); |
|
| 290 | + $item->set_quantity($value); |
|
| 291 | + if (0 == $value) { |
|
| 292 | + $item->set_quantity(1); |
|
| 293 | + $item->set_allow_quantities(true); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $prepared[] = $item; |
@@ -300,33 +300,33 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Items saved via payment forms editor. |
| 303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
| 303 | + if (is_array($value) && isset($value['id'])) { |
|
| 304 | 304 | |
| 305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
| 305 | + $item = new GetPaid_Form_Item($value['id']); |
|
| 306 | 306 | |
| 307 | - if ( ! $item->can_purchase() ) { |
|
| 307 | + if (!$item->can_purchase()) { |
|
| 308 | 308 | continue; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // Sub-total (Cart items). |
| 312 | - if ( isset( $value['subtotal'] ) ) { |
|
| 313 | - $item->set_price( $value['subtotal'] ); |
|
| 312 | + if (isset($value['subtotal'])) { |
|
| 313 | + $item->set_price($value['subtotal']); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( isset( $value['quantity'] ) ) { |
|
| 317 | - $item->set_quantity( $value['quantity'] ); |
|
| 316 | + if (isset($value['quantity'])) { |
|
| 317 | + $item->set_quantity($value['quantity']); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
| 321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
| 320 | + if (isset($value['allow_quantities'])) { |
|
| 321 | + $item->set_allow_quantities($value['allow_quantities']); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if ( isset( $value['required'] ) ) { |
|
| 325 | - $item->set_is_required( $value['required'] ); |
|
| 324 | + if (isset($value['required'])) { |
|
| 325 | + $item->set_is_required($value['required']); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( isset( $value['description'] ) ) { |
|
| 329 | - $item->set_custom_description( $value['description'] ); |
|
| 328 | + if (isset($value['description'])) { |
|
| 329 | + $item->set_custom_description($value['description']); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $prepared[] = $item; |
@@ -335,14 +335,14 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // $item_id => array( 'price' => 10 ) (item variations) |
| 338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
| 339 | - $item = new GetPaid_Form_Item( $key ); |
|
| 338 | + if (is_numeric($key) && is_array($value)) { |
|
| 339 | + $item = new GetPaid_Form_Item($key); |
|
| 340 | 340 | |
| 341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
| 342 | - $item->set_price( $value['price'] ); |
|
| 341 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
| 342 | + $item->set_price($value['price']); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - if ( $item->can_purchase() ) { |
|
| 345 | + if ($item->can_purchase()) { |
|
| 346 | 346 | $prepared[] = $item; |
| 347 | 347 | } |
| 348 | 348 | |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if ( 'objects' == $return && 'view' == $context ) { |
|
| 354 | + if ('objects' == $return && 'view' == $context) { |
|
| 355 | 355 | return $prepared; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | $items = array(); |
| 359 | - foreach ( $prepared as $item ) { |
|
| 359 | + foreach ($prepared as $item) { |
|
| 360 | 360 | $items[] = $item->prepare_data_for_use(); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -370,14 +370,14 @@ discard block |
||
| 370 | 370 | * @param int $item_id The item id to return. |
| 371 | 371 | * @return GetPaid_Form_Item|bool |
| 372 | 372 | */ |
| 373 | - public function get_item( $item_id ) { |
|
| 373 | + public function get_item($item_id) { |
|
| 374 | 374 | |
| 375 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
| 375 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
| 376 | 376 | return false; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - foreach( $this->get_items() as $item ) { |
|
| 380 | - if ( $item->get_id() == (int) $item_id ) { |
|
| 379 | + foreach ($this->get_items() as $item) { |
|
| 380 | + if ($item->get_id() == (int) $item_id) { |
|
| 381 | 381 | return $item; |
| 382 | 382 | } |
| 383 | 383 | } |
@@ -393,15 +393,15 @@ discard block |
||
| 393 | 393 | * @param string $element_type The element type to return. |
| 394 | 394 | * @return array|bool |
| 395 | 395 | */ |
| 396 | - public function get_element_type( $element_type ) { |
|
| 396 | + public function get_element_type($element_type) { |
|
| 397 | 397 | |
| 398 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
| 398 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
| 399 | 399 | return false; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
| 402 | + foreach ($this->get_prop('elements') as $element) { |
|
| 403 | 403 | |
| 404 | - if ( $element['type'] == $element_type ) { |
|
| 404 | + if ($element['type'] == $element_type) { |
|
| 405 | 405 | return $element; |
| 406 | 406 | } |
| 407 | 407 | |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | * @param string $context View or edit context. |
| 419 | 419 | * @return float |
| 420 | 420 | */ |
| 421 | - public function get_earned( $context = 'view' ) { |
|
| 422 | - return $this->get_prop( 'earned', $context ); |
|
| 421 | + public function get_earned($context = 'view') { |
|
| 422 | + return $this->get_prop('earned', $context); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
@@ -429,8 +429,8 @@ discard block |
||
| 429 | 429 | * @param string $context View or edit context. |
| 430 | 430 | * @return float |
| 431 | 431 | */ |
| 432 | - public function get_refunded( $context = 'view' ) { |
|
| 433 | - return $this->get_prop( 'refunded', $context ); |
|
| 432 | + public function get_refunded($context = 'view') { |
|
| 433 | + return $this->get_prop('refunded', $context); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -440,8 +440,8 @@ discard block |
||
| 440 | 440 | * @param string $context View or edit context. |
| 441 | 441 | * @return float |
| 442 | 442 | */ |
| 443 | - public function get_cancelled( $context = 'view' ) { |
|
| 444 | - return $this->get_prop( 'cancelled', $context ); |
|
| 443 | + public function get_cancelled($context = 'view') { |
|
| 444 | + return $this->get_prop('cancelled', $context); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
@@ -451,8 +451,8 @@ discard block |
||
| 451 | 451 | * @param string $context View or edit context. |
| 452 | 452 | * @return float |
| 453 | 453 | */ |
| 454 | - public function get_failed( $context = 'view' ) { |
|
| 455 | - return $this->get_prop( 'failed', $context ); |
|
| 454 | + public function get_failed($context = 'view') { |
|
| 455 | + return $this->get_prop('failed', $context); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -463,8 +463,8 @@ discard block |
||
| 463 | 463 | * @return string |
| 464 | 464 | */ |
| 465 | 465 | public function get_currency() { |
| 466 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 467 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
| 466 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
| 467 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /* |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | * |
| 483 | 483 | * @since 1.0.19 |
| 484 | 484 | */ |
| 485 | - public function set_version( $value ) { |
|
| 486 | - $this->set_prop( 'version', $value ); |
|
| 485 | + public function set_version($value) { |
|
| 486 | + $this->set_prop('version', $value); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
@@ -493,11 +493,11 @@ discard block |
||
| 493 | 493 | * @param string $value Value to set. |
| 494 | 494 | * @return bool Whether or not the date was set. |
| 495 | 495 | */ |
| 496 | - public function set_date_created( $value ) { |
|
| 497 | - $date = strtotime( $value ); |
|
| 496 | + public function set_date_created($value) { |
|
| 497 | + $date = strtotime($value); |
|
| 498 | 498 | |
| 499 | - if ( $date ) { |
|
| 500 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 499 | + if ($date) { |
|
| 500 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 501 | 501 | return true; |
| 502 | 502 | } |
| 503 | 503 | |
@@ -512,11 +512,11 @@ discard block |
||
| 512 | 512 | * @param string $value Value to set. |
| 513 | 513 | * @return bool Whether or not the date was set. |
| 514 | 514 | */ |
| 515 | - public function set_date_modified( $value ) { |
|
| 516 | - $date = strtotime( $value ); |
|
| 515 | + public function set_date_modified($value) { |
|
| 516 | + $date = strtotime($value); |
|
| 517 | 517 | |
| 518 | - if ( $date ) { |
|
| 519 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 518 | + if ($date) { |
|
| 519 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 520 | 520 | return true; |
| 521 | 521 | } |
| 522 | 522 | |
@@ -530,8 +530,8 @@ discard block |
||
| 530 | 530 | * @since 1.0.19 |
| 531 | 531 | * @param string $value New name. |
| 532 | 532 | */ |
| 533 | - public function set_name( $value ) { |
|
| 534 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
| 533 | + public function set_name($value) { |
|
| 534 | + $this->set_prop('name', sanitize_text_field($value)); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | * @since 1.0.19 |
| 541 | 541 | * @param string $value New name. |
| 542 | 542 | */ |
| 543 | - public function set_title( $value ) { |
|
| 544 | - $this->set_name( $value ); |
|
| 543 | + public function set_title($value) { |
|
| 544 | + $this->set_name($value); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -550,8 +550,8 @@ discard block |
||
| 550 | 550 | * @since 1.0.19 |
| 551 | 551 | * @param int $value New author. |
| 552 | 552 | */ |
| 553 | - public function set_author( $value ) { |
|
| 554 | - $this->set_prop( 'author', (int) $value ); |
|
| 553 | + public function set_author($value) { |
|
| 554 | + $this->set_prop('author', (int) $value); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | /** |
@@ -561,13 +561,13 @@ discard block |
||
| 561 | 561 | * @sinve 2.3.4 Array values sanitized. |
| 562 | 562 | * @param array $value Form elements. |
| 563 | 563 | */ |
| 564 | - public function set_elements( $value ) { |
|
| 565 | - if ( is_array( $value ) ) { |
|
| 564 | + public function set_elements($value) { |
|
| 565 | + if (is_array($value)) { |
|
| 566 | 566 | |
| 567 | 567 | // sanitize |
| 568 | - $value = $this->sanitize_array_values( $value ); |
|
| 568 | + $value = $this->sanitize_array_values($value); |
|
| 569 | 569 | |
| 570 | - $this->set_prop( 'elements', $value ); |
|
| 570 | + $this->set_prop('elements', $value); |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | * |
| 579 | 579 | * @return mixed |
| 580 | 580 | */ |
| 581 | - public function sanitize_array_values($value){ |
|
| 581 | + public function sanitize_array_values($value) { |
|
| 582 | 582 | |
| 583 | 583 | // sanitize |
| 584 | - if(!empty($value )){ |
|
| 584 | + if (!empty($value)) { |
|
| 585 | 585 | |
| 586 | - foreach($value as $key => $val_arr){ |
|
| 586 | + foreach ($value as $key => $val_arr) { |
|
| 587 | 587 | |
| 588 | - if(is_array($val_arr)){ |
|
| 588 | + if (is_array($val_arr)) { |
|
| 589 | 589 | // check if we have sub array items. |
| 590 | 590 | $sub_arr = array(); |
| 591 | - foreach($val_arr as $key2 => $val2){ |
|
| 592 | - if(is_array($val2)){ |
|
| 591 | + foreach ($val_arr as $key2 => $val2) { |
|
| 592 | + if (is_array($val2)) { |
|
| 593 | 593 | $sub_arr[$key2] = $this->sanitize_array_values($val2); |
| 594 | 594 | unset($val_arr[$key][$key2]); |
| 595 | 595 | } |
@@ -599,14 +599,14 @@ discard block |
||
| 599 | 599 | $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
| 600 | 600 | |
| 601 | 601 | // sanitize array elements |
| 602 | - $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
| 602 | + $value[$key] = array_map('sanitize_text_field', $val_arr); |
|
| 603 | 603 | |
| 604 | 604 | // add back the description if set |
| 605 | - if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
| 605 | + if (isset($val_arr['description'])) { $value[$key]['description'] = $help_text; } |
|
| 606 | 606 | |
| 607 | 607 | // add back sub array items after its been sanitized. |
| 608 | - if ( ! empty( $sub_arr ) ) { |
|
| 609 | - $value[$key] = array_merge($value[$key],$sub_arr); |
|
| 608 | + if (!empty($sub_arr)) { |
|
| 609 | + $value[$key] = array_merge($value[$key], $sub_arr); |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | |
@@ -623,9 +623,9 @@ discard block |
||
| 623 | 623 | * @since 1.0.19 |
| 624 | 624 | * @param array $value Form elements. |
| 625 | 625 | */ |
| 626 | - public function set_items( $value ) { |
|
| 627 | - if ( is_array( $value ) ) { |
|
| 628 | - $this->set_prop( 'items', $value ); |
|
| 626 | + public function set_items($value) { |
|
| 627 | + if (is_array($value)) { |
|
| 628 | + $this->set_prop('items', $value); |
|
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
@@ -635,9 +635,9 @@ discard block |
||
| 635 | 635 | * @since 1.0.19 |
| 636 | 636 | * @param float $value Amount earned. |
| 637 | 637 | */ |
| 638 | - public function set_earned( $value ) { |
|
| 639 | - $value = max( (float) $value, 0 ); |
|
| 640 | - $this->set_prop( 'earned', $value ); |
|
| 638 | + public function set_earned($value) { |
|
| 639 | + $value = max((float) $value, 0); |
|
| 640 | + $this->set_prop('earned', $value); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -646,9 +646,9 @@ discard block |
||
| 646 | 646 | * @since 1.0.19 |
| 647 | 647 | * @param float $value Amount refunded. |
| 648 | 648 | */ |
| 649 | - public function set_refunded( $value ) { |
|
| 650 | - $value = max( (float) $value, 0 ); |
|
| 651 | - $this->set_prop( 'refunded', $value ); |
|
| 649 | + public function set_refunded($value) { |
|
| 650 | + $value = max((float) $value, 0); |
|
| 651 | + $this->set_prop('refunded', $value); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
@@ -657,9 +657,9 @@ discard block |
||
| 657 | 657 | * @since 1.0.19 |
| 658 | 658 | * @param float $value Amount cancelled. |
| 659 | 659 | */ |
| 660 | - public function set_cancelled( $value ) { |
|
| 661 | - $value = max( (float) $value, 0 ); |
|
| 662 | - $this->set_prop( 'cancelled', $value ); |
|
| 660 | + public function set_cancelled($value) { |
|
| 661 | + $value = max((float) $value, 0); |
|
| 662 | + $this->set_prop('cancelled', $value); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** |
@@ -668,9 +668,9 @@ discard block |
||
| 668 | 668 | * @since 1.0.19 |
| 669 | 669 | * @param float $value Amount cancelled. |
| 670 | 670 | */ |
| 671 | - public function set_failed( $value ) { |
|
| 672 | - $value = max( (float) $value, 0 ); |
|
| 673 | - $this->set_prop( 'failed', $value ); |
|
| 671 | + public function set_failed($value) { |
|
| 672 | + $value = max((float) $value, 0); |
|
| 673 | + $this->set_prop('failed', $value); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
@@ -679,11 +679,11 @@ discard block |
||
| 679 | 679 | * @deprecated |
| 680 | 680 | * @return int item id |
| 681 | 681 | */ |
| 682 | - public function create( $data = array() ) { |
|
| 682 | + public function create($data = array()) { |
|
| 683 | 683 | |
| 684 | 684 | // Set the properties. |
| 685 | - if ( is_array( $data ) ) { |
|
| 686 | - $this->set_props( $data ); |
|
| 685 | + if (is_array($data)) { |
|
| 686 | + $this->set_props($data); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | // Save the item. |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | * @deprecated |
| 698 | 698 | * @return int item id |
| 699 | 699 | */ |
| 700 | - public function update( $data = array() ) { |
|
| 701 | - return $this->create( $data ); |
|
| 700 | + public function update($data = array()) { |
|
| 701 | + return $this->create($data); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /* |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | */ |
| 719 | 719 | public function is_default() { |
| 720 | 720 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
| 721 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
| 721 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -730,11 +730,11 @@ discard block |
||
| 730 | 730 | public function is_active() { |
| 731 | 731 | $is_active = 0 !== (int) $this->get_id(); |
| 732 | 732 | |
| 733 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
| 733 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
| 734 | 734 | $is_active = false; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
| 737 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
@@ -743,8 +743,8 @@ discard block |
||
| 743 | 743 | * @since 1.0.19 |
| 744 | 744 | * @return bool |
| 745 | 745 | */ |
| 746 | - public function has_item( $item_id ) { |
|
| 747 | - return false !== $this->get_item( $item_id ); |
|
| 746 | + public function has_item($item_id) { |
|
| 747 | + return false !== $this->get_item($item_id); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | /** |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | * @since 1.0.19 |
| 754 | 754 | * @return bool |
| 755 | 755 | */ |
| 756 | - public function has_element_type( $element_type ) { |
|
| 757 | - return false !== $this->get_element_type( $element_type ); |
|
| 756 | + public function has_element_type($element_type) { |
|
| 757 | + return false !== $this->get_element_type($element_type); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
@@ -765,13 +765,13 @@ discard block |
||
| 765 | 765 | */ |
| 766 | 766 | public function is_recurring() { |
| 767 | 767 | |
| 768 | - if ( ! empty( $this->invoice ) ) { |
|
| 768 | + if (!empty($this->invoice)) { |
|
| 769 | 769 | return $this->invoice->is_recurring(); |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - foreach ( $this->get_items() as $item ) { |
|
| 772 | + foreach ($this->get_items() as $item) { |
|
| 773 | 773 | |
| 774 | - if ( $item->is_recurring() ) { |
|
| 774 | + if ($item->is_recurring()) { |
|
| 775 | 775 | return true; |
| 776 | 776 | } |
| 777 | 777 | |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | * |
| 786 | 786 | * @since 1.0.19 |
| 787 | 787 | */ |
| 788 | - public function get_html( $extra_markup = '' ) { |
|
| 788 | + public function get_html($extra_markup = '') { |
|
| 789 | 789 | |
| 790 | 790 | // Return the HTML. |
| 791 | 791 | return wpinv_get_template_html( |
@@ -803,8 +803,8 @@ discard block |
||
| 803 | 803 | * |
| 804 | 804 | * @since 1.0.19 |
| 805 | 805 | */ |
| 806 | - public function display( $extra_markup = '' ) { |
|
| 807 | - echo $this->get_html( $extra_markup ); |
|
| 806 | + public function display($extra_markup = '') { |
|
| 807 | + echo $this->get_html($extra_markup); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | } |
@@ -12,114 +12,114 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Payment_Form_Submission_Fees { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * The fee validation error. |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - public $fee_error; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Submission fees. |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - public $fees = array(); |
|
| 15 | + /** |
|
| 16 | + * The fee validation error. |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + public $fee_error; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Submission fees. |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + public $fees = array(); |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Class constructor |
|
| 29 | + * |
|
| 30 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 31 | + */ |
|
| 32 | + public function __construct( $submission ) { |
|
| 33 | + |
|
| 34 | + // Process any existing invoice fees. |
|
| 35 | + if ( $submission->has_invoice() ) { |
|
| 36 | + $this->fees = $submission->get_invoice()->get_fees(); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // Process price fields. |
|
| 40 | + $data = $submission->get_data(); |
|
| 41 | + $payment_form = $submission->get_payment_form(); |
|
| 42 | + |
|
| 43 | + foreach ( $payment_form->get_elements() as $element ) { |
|
| 44 | + |
|
| 45 | + if ( 'price_input' == $element['type'] ) { |
|
| 46 | + $this->process_price_input( $element, $data, $submission ); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + if ( 'price_select' == $element['type'] ) { |
|
| 50 | + $this->process_price_select( $element, $data ); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Process a price input field. |
|
| 59 | + * |
|
| 60 | + * @param array $element |
|
| 61 | + * @param array $data |
|
| 62 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 63 | + */ |
|
| 64 | + public function process_price_input( $element, $data, $submission ) { |
|
| 65 | + |
|
| 66 | + // Abort if not passed. |
|
| 67 | + if ( empty( $data[ $element['id'] ] ) ) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $amount = (float) wpinv_sanitize_amount( $data[ $element['id'] ] ); |
|
| 72 | + $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] ); |
|
| 73 | + |
|
| 74 | + if ( $amount < $minimum ) { |
|
| 75 | + throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) ); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $this->fees[ $element['label'] ] = array( |
|
| 79 | + 'name' => $element['label'], |
|
| 80 | + 'initial_fee' => $amount, |
|
| 81 | + 'recurring_fee' => 0, |
|
| 82 | + ); |
|
| 83 | + |
|
| 84 | + } |
|
| 26 | 85 | |
| 27 | 86 | /** |
| 28 | - * Class constructor |
|
| 29 | - * |
|
| 30 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 31 | - */ |
|
| 32 | - public function __construct( $submission ) { |
|
| 33 | - |
|
| 34 | - // Process any existing invoice fees. |
|
| 35 | - if ( $submission->has_invoice() ) { |
|
| 36 | - $this->fees = $submission->get_invoice()->get_fees(); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // Process price fields. |
|
| 40 | - $data = $submission->get_data(); |
|
| 41 | - $payment_form = $submission->get_payment_form(); |
|
| 42 | - |
|
| 43 | - foreach ( $payment_form->get_elements() as $element ) { |
|
| 44 | - |
|
| 45 | - if ( 'price_input' == $element['type'] ) { |
|
| 46 | - $this->process_price_input( $element, $data, $submission ); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - if ( 'price_select' == $element['type'] ) { |
|
| 50 | - $this->process_price_select( $element, $data ); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Process a price input field. |
|
| 59 | - * |
|
| 60 | - * @param array $element |
|
| 61 | - * @param array $data |
|
| 62 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 63 | - */ |
|
| 64 | - public function process_price_input( $element, $data, $submission ) { |
|
| 65 | - |
|
| 66 | - // Abort if not passed. |
|
| 67 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
| 68 | - return; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $amount = (float) wpinv_sanitize_amount( $data[ $element['id'] ] ); |
|
| 72 | - $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] ); |
|
| 73 | - |
|
| 74 | - if ( $amount < $minimum ) { |
|
| 75 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) ); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $this->fees[ $element['label'] ] = array( |
|
| 79 | - 'name' => $element['label'], |
|
| 80 | - 'initial_fee' => $amount, |
|
| 81 | - 'recurring_fee' => 0, |
|
| 82 | - ); |
|
| 83 | - |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Process a price select field. |
|
| 88 | - * |
|
| 89 | - * @param array $element |
|
| 90 | - * @param array $data |
|
| 91 | - */ |
|
| 92 | - public function process_price_select( $element, $data ) { |
|
| 93 | - |
|
| 94 | - // Abort if not passed. |
|
| 95 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
| 96 | - return; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $options = getpaid_convert_price_string_to_options( $element['options'] ); |
|
| 100 | - $selected = array_filter( array_map( 'trim', explode( ',', $data[ $element['id'] ] ) ) ); |
|
| 101 | - $total = 0; |
|
| 102 | - $sub_labels = array(); |
|
| 103 | - |
|
| 104 | - foreach ( $selected as $price ) { |
|
| 105 | - |
|
| 106 | - if ( ! isset( $options[ $price ] ) ) { |
|
| 107 | - throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) ); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $price = explode( '|', $price ); |
|
| 111 | - |
|
| 112 | - $sub_labels[] = $price[0]; |
|
| 113 | - $total += (float) wpinv_sanitize_amount( $price[1] ); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $this->fees[ $element['label'] ] = array( |
|
| 117 | - 'name' => $element['label'], |
|
| 118 | - 'initial_fee' => $total, |
|
| 119 | - 'recurring_fee' => 0, |
|
| 120 | - 'description' => implode( ', ', $sub_labels ), |
|
| 121 | - ); |
|
| 122 | - |
|
| 123 | - } |
|
| 87 | + * Process a price select field. |
|
| 88 | + * |
|
| 89 | + * @param array $element |
|
| 90 | + * @param array $data |
|
| 91 | + */ |
|
| 92 | + public function process_price_select( $element, $data ) { |
|
| 93 | + |
|
| 94 | + // Abort if not passed. |
|
| 95 | + if ( empty( $data[ $element['id'] ] ) ) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $options = getpaid_convert_price_string_to_options( $element['options'] ); |
|
| 100 | + $selected = array_filter( array_map( 'trim', explode( ',', $data[ $element['id'] ] ) ) ); |
|
| 101 | + $total = 0; |
|
| 102 | + $sub_labels = array(); |
|
| 103 | + |
|
| 104 | + foreach ( $selected as $price ) { |
|
| 105 | + |
|
| 106 | + if ( ! isset( $options[ $price ] ) ) { |
|
| 107 | + throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) ); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $price = explode( '|', $price ); |
|
| 111 | + |
|
| 112 | + $sub_labels[] = $price[0]; |
|
| 113 | + $total += (float) wpinv_sanitize_amount( $price[1] ); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $this->fees[ $element['label'] ] = array( |
|
| 117 | + 'name' => $element['label'], |
|
| 118 | + 'initial_fee' => $total, |
|
| 119 | + 'recurring_fee' => 0, |
|
| 120 | + 'description' => implode( ', ', $sub_labels ), |
|
| 121 | + ); |
|
| 122 | + |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Payment form submission fees class |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
| 31 | 31 | */ |
| 32 | - public function __construct( $submission ) { |
|
| 32 | + public function __construct($submission) { |
|
| 33 | 33 | |
| 34 | 34 | // Process any existing invoice fees. |
| 35 | - if ( $submission->has_invoice() ) { |
|
| 35 | + if ($submission->has_invoice()) { |
|
| 36 | 36 | $this->fees = $submission->get_invoice()->get_fees(); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | $data = $submission->get_data(); |
| 41 | 41 | $payment_form = $submission->get_payment_form(); |
| 42 | 42 | |
| 43 | - foreach ( $payment_form->get_elements() as $element ) { |
|
| 43 | + foreach ($payment_form->get_elements() as $element) { |
|
| 44 | 44 | |
| 45 | - if ( 'price_input' == $element['type'] ) { |
|
| 46 | - $this->process_price_input( $element, $data, $submission ); |
|
| 45 | + if ('price_input' == $element['type']) { |
|
| 46 | + $this->process_price_input($element, $data, $submission); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if ( 'price_select' == $element['type'] ) { |
|
| 50 | - $this->process_price_select( $element, $data ); |
|
| 49 | + if ('price_select' == $element['type']) { |
|
| 50 | + $this->process_price_select($element, $data); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
@@ -61,21 +61,21 @@ discard block |
||
| 61 | 61 | * @param array $data |
| 62 | 62 | * @param GetPaid_Payment_Form_Submission $submission |
| 63 | 63 | */ |
| 64 | - public function process_price_input( $element, $data, $submission ) { |
|
| 64 | + public function process_price_input($element, $data, $submission) { |
|
| 65 | 65 | |
| 66 | 66 | // Abort if not passed. |
| 67 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
| 67 | + if (empty($data[$element['id']])) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $amount = (float) wpinv_sanitize_amount( $data[ $element['id'] ] ); |
|
| 72 | - $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] ); |
|
| 71 | + $amount = (float) wpinv_sanitize_amount($data[$element['id']]); |
|
| 72 | + $minimum = empty($element['minimum']) ? 0 : (float) wpinv_sanitize_amount($element['minimum']); |
|
| 73 | 73 | |
| 74 | - if ( $amount < $minimum ) { |
|
| 75 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) ); |
|
| 74 | + if ($amount < $minimum) { |
|
| 75 | + throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), wpinv_price($minimum, $submission->get_currency()))); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $this->fees[ $element['label'] ] = array( |
|
| 78 | + $this->fees[$element['label']] = array( |
|
| 79 | 79 | 'name' => $element['label'], |
| 80 | 80 | 'initial_fee' => $amount, |
| 81 | 81 | 'recurring_fee' => 0, |
@@ -89,35 +89,35 @@ discard block |
||
| 89 | 89 | * @param array $element |
| 90 | 90 | * @param array $data |
| 91 | 91 | */ |
| 92 | - public function process_price_select( $element, $data ) { |
|
| 92 | + public function process_price_select($element, $data) { |
|
| 93 | 93 | |
| 94 | 94 | // Abort if not passed. |
| 95 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
| 95 | + if (empty($data[$element['id']])) { |
|
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $options = getpaid_convert_price_string_to_options( $element['options'] ); |
|
| 100 | - $selected = array_filter( array_map( 'trim', explode( ',', $data[ $element['id'] ] ) ) ); |
|
| 99 | + $options = getpaid_convert_price_string_to_options($element['options']); |
|
| 100 | + $selected = array_filter(array_map('trim', explode(',', $data[$element['id']]))); |
|
| 101 | 101 | $total = 0; |
| 102 | 102 | $sub_labels = array(); |
| 103 | 103 | |
| 104 | - foreach ( $selected as $price ) { |
|
| 104 | + foreach ($selected as $price) { |
|
| 105 | 105 | |
| 106 | - if ( ! isset( $options[ $price ] ) ) { |
|
| 107 | - throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) ); |
|
| 106 | + if (!isset($options[$price])) { |
|
| 107 | + throw new Exception(__('You have selected an invalid amount', 'invoicing')); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $price = explode( '|', $price ); |
|
| 110 | + $price = explode('|', $price); |
|
| 111 | 111 | |
| 112 | 112 | $sub_labels[] = $price[0]; |
| 113 | - $total += (float) wpinv_sanitize_amount( $price[1] ); |
|
| 113 | + $total += (float) wpinv_sanitize_amount($price[1]); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $this->fees[ $element['label'] ] = array( |
|
| 116 | + $this->fees[$element['label']] = array( |
|
| 117 | 117 | 'name' => $element['label'], |
| 118 | 118 | 'initial_fee' => $total, |
| 119 | 119 | 'recurring_fee' => 0, |
| 120 | - 'description' => implode( ', ', $sub_labels ), |
|
| 120 | + 'description' => implode(', ', $sub_labels), |
|
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | 123 | } |
@@ -9,9 +9,9 @@ discard block |
||
| 9 | 9 | * @var array $fee |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | -do_action( 'getpaid_before_invoice_fee_item', $invoice, $fee ); |
|
| 14 | +do_action('getpaid_before_invoice_fee_item', $invoice, $fee); |
|
| 15 | 15 | |
| 16 | 16 | ?> |
| 17 | 17 | |
@@ -19,66 +19,66 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | <div class="form-row"> |
| 21 | 21 | |
| 22 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
| 22 | + <?php foreach (array_keys($columns) as $column): ?> |
|
| 23 | 23 | |
| 24 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
| 24 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
| 25 | 25 | |
| 26 | 26 | <?php |
| 27 | 27 | |
| 28 | 28 | // Fires before printing a fee item column. |
| 29 | - do_action( "getpaid_invoice_fee_item_before_$column", $fee, $invoice ); |
|
| 29 | + do_action("getpaid_invoice_fee_item_before_$column", $fee, $invoice); |
|
| 30 | 30 | |
| 31 | 31 | // Item name. |
| 32 | - if ( 'name' == $column ) { |
|
| 32 | + if ('name' == $column) { |
|
| 33 | 33 | |
| 34 | 34 | // Display the name. |
| 35 | - echo '<div class="mb-1">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
| 35 | + echo '<div class="mb-1">' . sanitize_text_field($fee['name']) . '</div>'; |
|
| 36 | 36 | |
| 37 | 37 | // And an optional description. |
| 38 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
| 38 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
| 39 | 39 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Item price. |
| 44 | - if ( 'price' == $column ) { |
|
| 44 | + if ('price' == $column) { |
|
| 45 | 45 | |
| 46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
| 47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 48 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 48 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 49 | 49 | } else { |
| 50 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 50 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Item quantity. |
| 56 | - if ( 'quantity' == $column ) { |
|
| 56 | + if ('quantity' == $column) { |
|
| 57 | 57 | echo "—"; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Item tax. |
| 61 | - if ( 'tax_rate' == $column ) { |
|
| 61 | + if ('tax_rate' == $column) { |
|
| 62 | 62 | echo "—"; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Item sub total. |
| 66 | - if ( 'subtotal' == $column ) { |
|
| 66 | + if ('subtotal' == $column) { |
|
| 67 | 67 | |
| 68 | 68 | // Display the item price (or recurring price if this is a renewal invoice) |
| 69 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 70 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 69 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 70 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 71 | 71 | } else { |
| 72 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 72 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // Fires when printing a fee item column. |
| 78 | - do_action( "getpaid_invoice_fee_item_$column", $fee, $invoice ); |
|
| 78 | + do_action("getpaid_invoice_fee_item_$column", $fee, $invoice); |
|
| 79 | 79 | |
| 80 | 80 | // Fires after printing a fee item column. |
| 81 | - do_action( "getpaid_invoice_fee_item_after_$column", $fee, $invoice ); |
|
| 81 | + do_action("getpaid_invoice_fee_item_after_$column", $fee, $invoice); |
|
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | 84 | |
@@ -10,68 +10,68 @@ discard block |
||
| 10 | 10 | * @var array $columns |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -defined( 'ABSPATH' ) || exit; |
|
| 13 | +defined('ABSPATH') || exit; |
|
| 14 | 14 | |
| 15 | 15 | ?> |
| 16 | 16 | |
| 17 | -<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?> |
|
| 17 | +<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?> |
|
| 18 | 18 | |
| 19 | 19 | <tr class="wpinv_cart_item item-fee"> |
| 20 | 20 | |
| 21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
| 21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
| 22 | 22 | |
| 23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
| 23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
| 24 | 24 | |
| 25 | 25 | <?php |
| 26 | 26 | |
| 27 | 27 | // Fires before printing a fee item column. |
| 28 | - do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice ); |
|
| 28 | + do_action("getpaid_email_fee_item_before_$column", $fee, $invoice); |
|
| 29 | 29 | |
| 30 | 30 | // Item name. |
| 31 | - if ( 'name' == $column ) { |
|
| 31 | + if ('name' == $column) { |
|
| 32 | 32 | |
| 33 | 33 | // Display the name. |
| 34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
| 34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($fee['name']) . '</div>'; |
|
| 35 | 35 | |
| 36 | 36 | // And an optional description. |
| 37 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
| 37 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
| 38 | 38 | echo "<p class='small'>$description</p>"; |
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Item price. |
| 43 | - if ( 'price' == $column ) { |
|
| 43 | + if ('price' == $column) { |
|
| 44 | 44 | |
| 45 | 45 | // Display the item price (or recurring price if this is a renewal invoice) |
| 46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 47 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 46 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 47 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 48 | 48 | } else { |
| 49 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 49 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Item quantity. |
| 55 | - if ( 'quantity' == $column ) { |
|
| 55 | + if ('quantity' == $column) { |
|
| 56 | 56 | echo "—"; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Item tax. |
| 60 | - if ( 'tax_rate' == $column ) { |
|
| 60 | + if ('tax_rate' == $column) { |
|
| 61 | 61 | echo "—"; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Item sub total. |
| 65 | - if ( 'subtotal' == $column ) { |
|
| 66 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 67 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 65 | + if ('subtotal' == $column) { |
|
| 66 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 67 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 68 | 68 | } else { |
| 69 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 69 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Fires when printing a line item column. |
| 74 | - do_action( "getpaid_email_fee_item_$column", $fee, $invoice ); |
|
| 74 | + do_action("getpaid_email_fee_item_$column", $fee, $invoice); |
|
| 75 | 75 | |
| 76 | 76 | ?> |
| 77 | 77 | |
@@ -81,4 +81,4 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | </tr> |
| 83 | 83 | |
| 84 | -<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?> |
|
| 84 | +<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?> |
|
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
| 26 | - define( 'WPINV_VERSION', '2.3.6' ); |
|
| 26 | + define( 'WPINV_VERSION', '2.3.6' ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return $GLOBALS['invoicing']; |
|
| 46 | + return $GLOBALS['invoicing']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -15,20 +15,20 @@ discard block |
||
| 15 | 15 | * @package GetPaid |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -defined( 'ABSPATH' ) || exit; |
|
| 18 | +defined('ABSPATH') || exit; |
|
| 19 | 19 | |
| 20 | 20 | // Define constants. |
| 21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
| 22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
| 21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
| 22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
| 26 | - define( 'WPINV_VERSION', '2.3.6' ); |
|
| 25 | +if (!defined('WPINV_VERSION')) { |
|
| 26 | + define('WPINV_VERSION', '2.3.6'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | // Include the main Invoicing class. |
| 30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
| 31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
| 30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
| 31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function getpaid() { |
| 41 | 41 | |
| 42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
| 42 | + if (empty($GLOBALS['invoicing'])) { |
|
| 43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @since 2.0.8 |
| 53 | 53 | */ |
| 54 | 54 | function getpaid_deactivation_hook() { |
| 55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
| 55 | + update_option('wpinv_flush_permalinks', 1); |
|
| 56 | 56 | } |
| 57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
| 57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Kickstart the plugin. |
| 67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
| 67 | +add_action('plugins_loaded', 'getpaid', -100); |
|
@@ -12,145 +12,145 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Daily_Maintenance { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class constructor. |
|
| 17 | - */ |
|
| 18 | - public function __construct(){ |
|
| 19 | - |
|
| 20 | - // Clear deprecated events. |
|
| 21 | - add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
| 22 | - |
|
| 23 | - // (Maybe) schedule a cron that runs daily. |
|
| 24 | - add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
| 25 | - |
|
| 26 | - // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
|
| 27 | - add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) ); |
|
| 28 | - add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
| 29 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
| 30 | - add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) ); |
|
| 31 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) ); |
|
| 32 | - |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Schedules a cron to run every day at 7 a.m |
|
| 37 | - * |
|
| 38 | - */ |
|
| 39 | - public function maybe_create_scheduled_event() { |
|
| 40 | - |
|
| 41 | - if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
| 42 | - $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
| 43 | - wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Clears deprecated events. |
|
| 50 | - * |
|
| 51 | - */ |
|
| 52 | - public function maybe_clear_deprecated_events() { |
|
| 53 | - |
|
| 54 | - if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
| 55 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 56 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
| 57 | - update_option( 'wpinv_cleared_old_events', 1 ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Fires the old hook for backwards compatibility. |
|
| 64 | - * |
|
| 65 | - */ |
|
| 66 | - public function backwards_compat() { |
|
| 67 | - do_action( 'wpinv_register_schedule_event_daily' ); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Checks for subscriptions that are scheduled to renew. |
|
| 72 | - * |
|
| 73 | - */ |
|
| 74 | - public function check_renewing_subscriptions() { |
|
| 75 | - |
|
| 76 | - // Fetch subscriptions that expire today. |
|
| 77 | - $args = array( |
|
| 78 | - 'number' => -1, |
|
| 79 | - 'count_total' => false, |
|
| 80 | - 'status' => 'trialling active', |
|
| 81 | - 'date_expires_query' => array( |
|
| 82 | - array( |
|
| 83 | - 'year' => date( 'Y', current_time( 'timestamp' ) ), |
|
| 84 | - 'month' => date( 'n', current_time( 'timestamp' ) ), |
|
| 85 | - 'day' => date( 'j', current_time( 'timestamp' ) ), |
|
| 86 | - 'compare' => '=', |
|
| 87 | - ), |
|
| 88 | - ), |
|
| 89 | - ); |
|
| 90 | - |
|
| 91 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 92 | - |
|
| 93 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 94 | - |
|
| 95 | - /** @var WPInv_Subscription $subscription */ |
|
| 96 | - if ( $subscription->is_last_renewal() ) { |
|
| 97 | - $subscription->complete(); |
|
| 98 | - } else { |
|
| 99 | - do_action( 'getpaid_should_renew_subscription', $subscription ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Expires expired subscriptions. |
|
| 108 | - * |
|
| 109 | - */ |
|
| 110 | - public function maybe_expire_subscriptions() { |
|
| 111 | - |
|
| 112 | - // Fetch expired subscriptions (skips those that expire today). |
|
| 113 | - $args = array( |
|
| 114 | - 'number' => -1, |
|
| 115 | - 'count_total' => false, |
|
| 116 | - 'status' => 'trialling active failing cancelled', |
|
| 117 | - 'date_expires_query' => array( |
|
| 118 | - 'before' => 'today', |
|
| 119 | - 'inclusive' => false, |
|
| 120 | - ), |
|
| 121 | - ); |
|
| 122 | - |
|
| 123 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 124 | - |
|
| 125 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 126 | - if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) { |
|
| 127 | - $subscription->set_status( 'expired' ); |
|
| 128 | - $subscription->save(); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Logs cron runs. |
|
| 136 | - * |
|
| 137 | - */ |
|
| 138 | - public function log_cron_run() { |
|
| 139 | - wpinv_error_log( 'GetPaid Daily Cron', false ); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Updates GeoIP databases. |
|
| 144 | - * |
|
| 145 | - */ |
|
| 146 | - public function maybe_update_geoip_databases() { |
|
| 147 | - $updated = get_transient( 'getpaid_updated_geoip_databases' ); |
|
| 148 | - |
|
| 149 | - if ( false === $updated ) { |
|
| 150 | - set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS ); |
|
| 151 | - do_action( 'getpaid_update_geoip_databases' ); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - } |
|
| 15 | + /** |
|
| 16 | + * Class constructor. |
|
| 17 | + */ |
|
| 18 | + public function __construct(){ |
|
| 19 | + |
|
| 20 | + // Clear deprecated events. |
|
| 21 | + add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
| 22 | + |
|
| 23 | + // (Maybe) schedule a cron that runs daily. |
|
| 24 | + add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
| 25 | + |
|
| 26 | + // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
|
| 27 | + add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) ); |
|
| 28 | + add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
| 29 | + add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
| 30 | + add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) ); |
|
| 31 | + add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) ); |
|
| 32 | + |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Schedules a cron to run every day at 7 a.m |
|
| 37 | + * |
|
| 38 | + */ |
|
| 39 | + public function maybe_create_scheduled_event() { |
|
| 40 | + |
|
| 41 | + if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
| 42 | + $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
| 43 | + wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Clears deprecated events. |
|
| 50 | + * |
|
| 51 | + */ |
|
| 52 | + public function maybe_clear_deprecated_events() { |
|
| 53 | + |
|
| 54 | + if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
| 55 | + wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 56 | + wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
| 57 | + update_option( 'wpinv_cleared_old_events', 1 ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Fires the old hook for backwards compatibility. |
|
| 64 | + * |
|
| 65 | + */ |
|
| 66 | + public function backwards_compat() { |
|
| 67 | + do_action( 'wpinv_register_schedule_event_daily' ); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Checks for subscriptions that are scheduled to renew. |
|
| 72 | + * |
|
| 73 | + */ |
|
| 74 | + public function check_renewing_subscriptions() { |
|
| 75 | + |
|
| 76 | + // Fetch subscriptions that expire today. |
|
| 77 | + $args = array( |
|
| 78 | + 'number' => -1, |
|
| 79 | + 'count_total' => false, |
|
| 80 | + 'status' => 'trialling active', |
|
| 81 | + 'date_expires_query' => array( |
|
| 82 | + array( |
|
| 83 | + 'year' => date( 'Y', current_time( 'timestamp' ) ), |
|
| 84 | + 'month' => date( 'n', current_time( 'timestamp' ) ), |
|
| 85 | + 'day' => date( 'j', current_time( 'timestamp' ) ), |
|
| 86 | + 'compare' => '=', |
|
| 87 | + ), |
|
| 88 | + ), |
|
| 89 | + ); |
|
| 90 | + |
|
| 91 | + $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 92 | + |
|
| 93 | + foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 94 | + |
|
| 95 | + /** @var WPInv_Subscription $subscription */ |
|
| 96 | + if ( $subscription->is_last_renewal() ) { |
|
| 97 | + $subscription->complete(); |
|
| 98 | + } else { |
|
| 99 | + do_action( 'getpaid_should_renew_subscription', $subscription ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Expires expired subscriptions. |
|
| 108 | + * |
|
| 109 | + */ |
|
| 110 | + public function maybe_expire_subscriptions() { |
|
| 111 | + |
|
| 112 | + // Fetch expired subscriptions (skips those that expire today). |
|
| 113 | + $args = array( |
|
| 114 | + 'number' => -1, |
|
| 115 | + 'count_total' => false, |
|
| 116 | + 'status' => 'trialling active failing cancelled', |
|
| 117 | + 'date_expires_query' => array( |
|
| 118 | + 'before' => 'today', |
|
| 119 | + 'inclusive' => false, |
|
| 120 | + ), |
|
| 121 | + ); |
|
| 122 | + |
|
| 123 | + $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 124 | + |
|
| 125 | + foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 126 | + if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) { |
|
| 127 | + $subscription->set_status( 'expired' ); |
|
| 128 | + $subscription->save(); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Logs cron runs. |
|
| 136 | + * |
|
| 137 | + */ |
|
| 138 | + public function log_cron_run() { |
|
| 139 | + wpinv_error_log( 'GetPaid Daily Cron', false ); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Updates GeoIP databases. |
|
| 144 | + * |
|
| 145 | + */ |
|
| 146 | + public function maybe_update_geoip_databases() { |
|
| 147 | + $updated = get_transient( 'getpaid_updated_geoip_databases' ); |
|
| 148 | + |
|
| 149 | + if ( false === $updated ) { |
|
| 150 | + set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS ); |
|
| 151 | + do_action( 'getpaid_update_geoip_databases' ); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | 156 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Daily maintenance class. |
@@ -15,20 +15,20 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Class constructor. |
| 17 | 17 | */ |
| 18 | - public function __construct(){ |
|
| 18 | + public function __construct() { |
|
| 19 | 19 | |
| 20 | 20 | // Clear deprecated events. |
| 21 | - add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
| 21 | + add_action('wp', array($this, 'maybe_clear_deprecated_events')); |
|
| 22 | 22 | |
| 23 | 23 | // (Maybe) schedule a cron that runs daily. |
| 24 | - add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
| 24 | + add_action('wp', array($this, 'maybe_create_scheduled_event')); |
|
| 25 | 25 | |
| 26 | 26 | // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
| 27 | - add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) ); |
|
| 28 | - add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
| 29 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
| 30 | - add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) ); |
|
| 31 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) ); |
|
| 27 | + add_action('getpaid_daily_maintenance', array($this, 'log_cron_run')); |
|
| 28 | + add_action('getpaid_daily_maintenance', array($this, 'backwards_compat')); |
|
| 29 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions')); |
|
| 30 | + add_action('getpaid_daily_maintenance', array($this, 'check_renewing_subscriptions')); |
|
| 31 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_update_geoip_databases')); |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function maybe_create_scheduled_event() { |
| 40 | 40 | |
| 41 | - if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
| 42 | - $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
| 43 | - wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
| 41 | + if (!wp_next_scheduled('getpaid_daily_maintenance')) { |
|
| 42 | + $timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp')); |
|
| 43 | + wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function maybe_clear_deprecated_events() { |
| 53 | 53 | |
| 54 | - if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
| 55 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 56 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
| 57 | - update_option( 'wpinv_cleared_old_events', 1 ); |
|
| 54 | + if (!get_option('wpinv_cleared_old_events')) { |
|
| 55 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
| 56 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_daily'); |
|
| 57 | + update_option('wpinv_cleared_old_events', 1); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | */ |
| 66 | 66 | public function backwards_compat() { |
| 67 | - do_action( 'wpinv_register_schedule_event_daily' ); |
|
| 67 | + do_action('wpinv_register_schedule_event_daily'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,29 +74,29 @@ discard block |
||
| 74 | 74 | public function check_renewing_subscriptions() { |
| 75 | 75 | |
| 76 | 76 | // Fetch subscriptions that expire today. |
| 77 | - $args = array( |
|
| 77 | + $args = array( |
|
| 78 | 78 | 'number' => -1, |
| 79 | 79 | 'count_total' => false, |
| 80 | 80 | 'status' => 'trialling active', |
| 81 | 81 | 'date_expires_query' => array( |
| 82 | 82 | array( |
| 83 | - 'year' => date( 'Y', current_time( 'timestamp' ) ), |
|
| 84 | - 'month' => date( 'n', current_time( 'timestamp' ) ), |
|
| 85 | - 'day' => date( 'j', current_time( 'timestamp' ) ), |
|
| 83 | + 'year' => date('Y', current_time('timestamp')), |
|
| 84 | + 'month' => date('n', current_time('timestamp')), |
|
| 85 | + 'day' => date('j', current_time('timestamp')), |
|
| 86 | 86 | 'compare' => '=', |
| 87 | 87 | ), |
| 88 | 88 | ), |
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 91 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
| 92 | 92 | |
| 93 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 93 | + foreach ($subscriptions->get_results() as $subscription) { |
|
| 94 | 94 | |
| 95 | 95 | /** @var WPInv_Subscription $subscription */ |
| 96 | - if ( $subscription->is_last_renewal() ) { |
|
| 96 | + if ($subscription->is_last_renewal()) { |
|
| 97 | 97 | $subscription->complete(); |
| 98 | 98 | } else { |
| 99 | - do_action( 'getpaid_should_renew_subscription', $subscription ); |
|
| 99 | + do_action('getpaid_should_renew_subscription', $subscription); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | public function maybe_expire_subscriptions() { |
| 111 | 111 | |
| 112 | 112 | // Fetch expired subscriptions (skips those that expire today). |
| 113 | - $args = array( |
|
| 113 | + $args = array( |
|
| 114 | 114 | 'number' => -1, |
| 115 | 115 | 'count_total' => false, |
| 116 | 116 | 'status' => 'trialling active failing cancelled', |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | ), |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
| 123 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
| 124 | 124 | |
| 125 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
| 126 | - if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', true, $subscription ) ) { |
|
| 127 | - $subscription->set_status( 'expired' ); |
|
| 125 | + foreach ($subscriptions->get_results() as $subscription) { |
|
| 126 | + if (apply_filters('getpaid_daily_maintenance_should_expire_subscription', true, $subscription)) { |
|
| 127 | + $subscription->set_status('expired'); |
|
| 128 | 128 | $subscription->save(); |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | */ |
| 138 | 138 | public function log_cron_run() { |
| 139 | - wpinv_error_log( 'GetPaid Daily Cron', false ); |
|
| 139 | + wpinv_error_log('GetPaid Daily Cron', false); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | */ |
| 146 | 146 | public function maybe_update_geoip_databases() { |
| 147 | - $updated = get_transient( 'getpaid_updated_geoip_databases' ); |
|
| 147 | + $updated = get_transient('getpaid_updated_geoip_databases'); |
|
| 148 | 148 | |
| 149 | - if ( false === $updated ) { |
|
| 150 | - set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS ); |
|
| 151 | - do_action( 'getpaid_update_geoip_databases' ); |
|
| 149 | + if (false === $updated) { |
|
| 150 | + set_transient('getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS); |
|
| 151 | + do_action('getpaid_update_geoip_databases'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | } |
@@ -13,58 +13,58 @@ discard block |
||
| 13 | 13 | class GetPaid_Authorize_Net_Gateway extends GetPaid_Authorize_Net_Legacy_Gateway { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $id = 'authorizenet'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * An array of features that this gateway supports. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 23 | + * An array of features that this gateway supports. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | 27 | protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Payment method order. |
|
| 31 | - * |
|
| 32 | - * @var int |
|
| 33 | - */ |
|
| 30 | + * Payment method order. |
|
| 31 | + * |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | 34 | public $order = 4; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Endpoint for requests from Authorize.net. |
|
| 38 | - * |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - protected $notify_url; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Endpoint for requests to Authorize.net. |
|
| 45 | - * |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 37 | + * Endpoint for requests from Authorize.net. |
|
| 38 | + * |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + protected $notify_url; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Endpoint for requests to Authorize.net. |
|
| 45 | + * |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | 48 | protected $endpoint; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * Currencies this gateway is allowed for. |
|
| 52 | - * |
|
| 53 | - * @var array |
|
| 54 | - */ |
|
| 55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
| 51 | + * Currencies this gateway is allowed for. |
|
| 52 | + * |
|
| 53 | + * @var array |
|
| 54 | + */ |
|
| 55 | + public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * URL to view a transaction. |
|
| 59 | - * |
|
| 60 | - * @var string |
|
| 61 | - */ |
|
| 58 | + * URL to view a transaction. |
|
| 59 | + * |
|
| 60 | + * @var string |
|
| 61 | + */ |
|
| 62 | 62 | public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s'; |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * Class constructor. |
|
| 66 | - */ |
|
| 67 | - public function __construct() { |
|
| 65 | + * Class constructor. |
|
| 66 | + */ |
|
| 67 | + public function __construct() { |
|
| 68 | 68 | |
| 69 | 69 | $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
| 70 | 70 | $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Displays the payment method select field. |
|
| 80 | - * |
|
| 81 | - * @param int $invoice_id 0 or invoice id. |
|
| 82 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
| 83 | - */ |
|
| 79 | + * Displays the payment method select field. |
|
| 80 | + * |
|
| 81 | + * @param int $invoice_id 0 or invoice id. |
|
| 82 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
| 83 | + */ |
|
| 84 | 84 | public function payment_fields( $invoice_id, $form ) { |
| 85 | 85 | |
| 86 | 86 | // Let the user select a payment method. |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * Creates a customer profile. |
|
| 95 | - * |
|
| 96 | - * |
|
| 97 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 94 | + * Creates a customer profile. |
|
| 95 | + * |
|
| 96 | + * |
|
| 97 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 98 | 98 | * @param array $submission_data Posted checkout fields. |
| 99 | 99 | * @param bool $save Whether or not to save the payment as a token. |
| 100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 101 | - * @return string|WP_Error Payment profile id. |
|
| 102 | - */ |
|
| 103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
| 101 | + * @return string|WP_Error Payment profile id. |
|
| 102 | + */ |
|
| 103 | + public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
| 104 | 104 | |
| 105 | 105 | // Remove non-digits from the number |
| 106 | 106 | $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | - * Retrieves a customer profile. |
|
| 179 | - * |
|
| 180 | - * |
|
| 181 | - * @param string $profile_id profile id. |
|
| 182 | - * @return string|WP_Error Profile id. |
|
| 178 | + * Retrieves a customer profile. |
|
| 179 | + * |
|
| 180 | + * |
|
| 181 | + * @param string $profile_id profile id. |
|
| 182 | + * @return string|WP_Error Profile id. |
|
| 183 | 183 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
| 184 | - */ |
|
| 185 | - public function get_customer_profile( $profile_id ) { |
|
| 184 | + */ |
|
| 185 | + public function get_customer_profile( $profile_id ) { |
|
| 186 | 186 | |
| 187 | 187 | // Generate args. |
| 188 | 188 | $args = array( |
@@ -197,17 +197,17 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | - * Creates a customer profile. |
|
| 201 | - * |
|
| 202 | - * |
|
| 200 | + * Creates a customer profile. |
|
| 201 | + * |
|
| 202 | + * |
|
| 203 | 203 | * @param string $profile_id profile id. |
| 204 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 204 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 205 | 205 | * @param array $submission_data Posted checkout fields. |
| 206 | 206 | * @param bool $save Whether or not to save the payment as a token. |
| 207 | 207 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 208 | - * @return string|WP_Error Profile id. |
|
| 209 | - */ |
|
| 210 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
| 208 | + * @return string|WP_Error Profile id. |
|
| 209 | + */ |
|
| 210 | + public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
| 211 | 211 | |
| 212 | 212 | // Remove non-digits from the number |
| 213 | 213 | $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
@@ -282,13 +282,13 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
| 285 | - * Retrieves payment details from cache. |
|
| 286 | - * |
|
| 287 | - * |
|
| 285 | + * Retrieves payment details from cache. |
|
| 286 | + * |
|
| 287 | + * |
|
| 288 | 288 | * @param array $payment_details. |
| 289 | - * @return array|false Profile id. |
|
| 290 | - */ |
|
| 291 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
| 289 | + * @return array|false Profile id. |
|
| 290 | + */ |
|
| 291 | + public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
| 292 | 292 | |
| 293 | 293 | $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
| 294 | 294 | $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
@@ -313,13 +313,13 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
| 316 | - * Securely adds payment details to cache. |
|
| 317 | - * |
|
| 318 | - * |
|
| 316 | + * Securely adds payment details to cache. |
|
| 317 | + * |
|
| 318 | + * |
|
| 319 | 319 | * @param array $payment_details. |
| 320 | 320 | * @param string $payment_profile_id. |
| 321 | - */ |
|
| 322 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
| 321 | + */ |
|
| 322 | + public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
| 323 | 323 | |
| 324 | 324 | $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
| 325 | 325 | $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
@@ -331,15 +331,15 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | - * Retrieves a customer payment profile. |
|
| 335 | - * |
|
| 336 | - * |
|
| 337 | - * @param string $customer_profile_id customer profile id. |
|
| 334 | + * Retrieves a customer payment profile. |
|
| 335 | + * |
|
| 336 | + * |
|
| 337 | + * @param string $customer_profile_id customer profile id. |
|
| 338 | 338 | * @param string $payment_profile_id payment profile id. |
| 339 | - * @return string|WP_Error Profile id. |
|
| 339 | + * @return string|WP_Error Profile id. |
|
| 340 | 340 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
| 341 | - */ |
|
| 342 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
| 341 | + */ |
|
| 342 | + public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
| 343 | 343 | |
| 344 | 344 | // Generate args. |
| 345 | 345 | $args = array( |
@@ -355,15 +355,15 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
| 358 | - * Charges a customer payment profile. |
|
| 359 | - * |
|
| 358 | + * Charges a customer payment profile. |
|
| 359 | + * |
|
| 360 | 360 | * @param string $customer_profile_id customer profile id. |
| 361 | 361 | * @param string $payment_profile_id payment profile id. |
| 362 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 362 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 363 | 363 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
| 364 | - * @return WP_Error|object |
|
| 365 | - */ |
|
| 366 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
| 364 | + * @return WP_Error|object |
|
| 365 | + */ |
|
| 366 | + public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
| 367 | 367 | |
| 368 | 368 | // Generate args. |
| 369 | 369 | $args = array( |
@@ -409,41 +409,41 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | - * Processes a customer charge. |
|
| 413 | - * |
|
| 412 | + * Processes a customer charge. |
|
| 413 | + * |
|
| 414 | 414 | * @param stdClass $result Api response. |
| 415 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 416 | - */ |
|
| 417 | - public function process_charge_response( $result, $invoice ) { |
|
| 415 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 416 | + */ |
|
| 417 | + public function process_charge_response( $result, $invoice ) { |
|
| 418 | 418 | |
| 419 | 419 | wpinv_clear_errors(); |
| 420 | - $response_code = (int) $result->transactionResponse->responseCode; |
|
| 420 | + $response_code = (int) $result->transactionResponse->responseCode; |
|
| 421 | 421 | |
| 422 | - // Succeeded. |
|
| 423 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
| 422 | + // Succeeded. |
|
| 423 | + if ( 1 == $response_code || 4 == $response_code ) { |
|
| 424 | 424 | |
| 425 | - // Maybe set a transaction id. |
|
| 426 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
| 427 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
| 428 | - } |
|
| 425 | + // Maybe set a transaction id. |
|
| 426 | + if ( ! empty( $result->transactionResponse->transId ) ) { |
|
| 427 | + $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
| 430 | + $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
| 431 | 431 | |
| 432 | - if ( 1 == $response_code ) { |
|
| 433 | - return $invoice->mark_paid(); |
|
| 434 | - } |
|
| 432 | + if ( 1 == $response_code ) { |
|
| 433 | + return $invoice->mark_paid(); |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | - $invoice->set_status( 'wpi-onhold' ); |
|
| 437 | - $invoice->add_note( |
|
| 436 | + $invoice->set_status( 'wpi-onhold' ); |
|
| 437 | + $invoice->add_note( |
|
| 438 | 438 | sprintf( |
| 439 | 439 | __( 'Held for review: %s', 'invoicing' ), |
| 440 | 440 | $result->transactionResponse->messages->message[0]->description |
| 441 | 441 | ) |
| 442 | - ); |
|
| 442 | + ); |
|
| 443 | 443 | |
| 444 | - return $invoice->save(); |
|
| 444 | + return $invoice->save(); |
|
| 445 | 445 | |
| 446 | - } |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | 448 | wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
| 449 | 449 | |
@@ -455,13 +455,13 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | /** |
| 458 | - * Returns payment information. |
|
| 459 | - * |
|
| 460 | - * |
|
| 461 | - * @param array $card Card details. |
|
| 462 | - * @return array |
|
| 463 | - */ |
|
| 464 | - public function get_payment_information( $card ) { |
|
| 458 | + * Returns payment information. |
|
| 459 | + * |
|
| 460 | + * |
|
| 461 | + * @param array $card Card details. |
|
| 462 | + * @return array |
|
| 463 | + */ |
|
| 464 | + public function get_payment_information( $card ) { |
|
| 465 | 465 | return array( |
| 466 | 466 | |
| 467 | 467 | 'creditCard' => array ( |
@@ -474,25 +474,25 @@ discard block |
||
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
| 477 | - * Returns the customer profile meta name. |
|
| 478 | - * |
|
| 479 | - * |
|
| 480 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 481 | - * @return string |
|
| 482 | - */ |
|
| 483 | - public function get_customer_profile_meta_name( $invoice ) { |
|
| 477 | + * Returns the customer profile meta name. |
|
| 478 | + * |
|
| 479 | + * |
|
| 480 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 481 | + * @return string |
|
| 482 | + */ |
|
| 483 | + public function get_customer_profile_meta_name( $invoice ) { |
|
| 484 | 484 | return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
| 488 | - * Validates the submitted data. |
|
| 489 | - * |
|
| 490 | - * |
|
| 491 | - * @param array $submission_data Posted checkout fields. |
|
| 488 | + * Validates the submitted data. |
|
| 489 | + * |
|
| 490 | + * |
|
| 491 | + * @param array $submission_data Posted checkout fields. |
|
| 492 | 492 | * @param WPInv_Invoice $invoice |
| 493 | - * @return WP_Error|string The payment profile id |
|
| 494 | - */ |
|
| 495 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
| 493 | + * @return WP_Error|string The payment profile id |
|
| 494 | + */ |
|
| 495 | + public function validate_submission_data( $submission_data, $invoice ) { |
|
| 496 | 496 | |
| 497 | 497 | // Validate authentication details. |
| 498 | 498 | $auth = $this->get_auth_params(); |
@@ -524,13 +524,13 @@ discard block |
||
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
| 527 | - * Returns invoice line items. |
|
| 528 | - * |
|
| 529 | - * |
|
| 530 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 531 | - * @return array |
|
| 532 | - */ |
|
| 533 | - public function get_line_items( $invoice ) { |
|
| 527 | + * Returns invoice line items. |
|
| 528 | + * |
|
| 529 | + * |
|
| 530 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 531 | + * @return array |
|
| 532 | + */ |
|
| 533 | + public function get_line_items( $invoice ) { |
|
| 534 | 534 | $items = array(); |
| 535 | 535 | |
| 536 | 536 | foreach ( $invoice->get_items() as $item ) { |
@@ -568,15 +568,15 @@ discard block |
||
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | /** |
| 571 | - * Process Payment. |
|
| 572 | - * |
|
| 573 | - * |
|
| 574 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 575 | - * @param array $submission_data Posted checkout fields. |
|
| 576 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 577 | - * @return array |
|
| 578 | - */ |
|
| 579 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 571 | + * Process Payment. |
|
| 572 | + * |
|
| 573 | + * |
|
| 574 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 575 | + * @param array $submission_data Posted checkout fields. |
|
| 576 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 577 | + * @return array |
|
| 578 | + */ |
|
| 579 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 580 | 580 | |
| 581 | 581 | // Validate the submitted data. |
| 582 | 582 | $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
@@ -609,45 +609,45 @@ discard block |
||
| 609 | 609 | |
| 610 | 610 | exit; |
| 611 | 611 | |
| 612 | - } |
|
| 612 | + } |
|
| 613 | 613 | |
| 614 | - /** |
|
| 615 | - * Processes the initial payment. |
|
| 616 | - * |
|
| 614 | + /** |
|
| 615 | + * Processes the initial payment. |
|
| 616 | + * |
|
| 617 | 617 | * @param WPInv_Invoice $invoice Invoice. |
| 618 | - */ |
|
| 619 | - protected function process_initial_payment( $invoice ) { |
|
| 618 | + */ |
|
| 619 | + protected function process_initial_payment( $invoice ) { |
|
| 620 | 620 | |
| 621 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 621 | + $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 622 | 622 | $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
| 623 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 623 | + $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 624 | 624 | |
| 625 | - // Do we have an error? |
|
| 626 | - if ( is_wp_error( $result ) ) { |
|
| 627 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 628 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 629 | - } |
|
| 625 | + // Do we have an error? |
|
| 626 | + if ( is_wp_error( $result ) ) { |
|
| 627 | + wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 628 | + wpinv_send_back_to_checkout( $invoice ); |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | - // Process the response. |
|
| 632 | - $this->process_charge_response( $result, $invoice ); |
|
| 631 | + // Process the response. |
|
| 632 | + $this->process_charge_response( $result, $invoice ); |
|
| 633 | 633 | |
| 634 | - if ( wpinv_get_errors() ) { |
|
| 635 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 636 | - } |
|
| 634 | + if ( wpinv_get_errors() ) { |
|
| 635 | + wpinv_send_back_to_checkout( $invoice ); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - } |
|
| 638 | + } |
|
| 639 | 639 | |
| 640 | 640 | /** |
| 641 | - * Processes recurring payments. |
|
| 642 | - * |
|
| 641 | + * Processes recurring payments. |
|
| 642 | + * |
|
| 643 | 643 | * @param WPInv_Invoice $invoice Invoice. |
| 644 | 644 | * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions. |
| 645 | - */ |
|
| 646 | - public function process_subscription( $invoice, $subscriptions ) { |
|
| 645 | + */ |
|
| 646 | + public function process_subscription( $invoice, $subscriptions ) { |
|
| 647 | 647 | |
| 648 | 648 | // Check if there is an initial amount to charge. |
| 649 | 649 | if ( (float) $invoice->get_total() > 0 ) { |
| 650 | - $this->process_initial_payment( $invoice ); |
|
| 650 | + $this->process_initial_payment( $invoice ); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | // Activate the subscriptions. |
@@ -665,36 +665,36 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | - // Redirect to the success page. |
|
| 668 | + // Redirect to the success page. |
|
| 669 | 669 | wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
| 670 | 670 | |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - /** |
|
| 674 | - * (Maybe) renews an authorize.net subscription profile. |
|
| 675 | - * |
|
| 676 | - * |
|
| 673 | + /** |
|
| 674 | + * (Maybe) renews an authorize.net subscription profile. |
|
| 675 | + * |
|
| 676 | + * |
|
| 677 | 677 | * @param WPInv_Subscription $subscription |
| 678 | - */ |
|
| 679 | - public function maybe_renew_subscription( $subscription ) { |
|
| 678 | + */ |
|
| 679 | + public function maybe_renew_subscription( $subscription ) { |
|
| 680 | 680 | |
| 681 | 681 | // Ensure its our subscription && it's active. |
| 682 | 682 | if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
| 683 | 683 | $this->renew_subscription( $subscription ); |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - } |
|
| 686 | + } |
|
| 687 | 687 | |
| 688 | 688 | /** |
| 689 | - * Renews a subscription. |
|
| 690 | - * |
|
| 689 | + * Renews a subscription. |
|
| 690 | + * |
|
| 691 | 691 | * @param WPInv_Subscription $subscription |
| 692 | - */ |
|
| 693 | - public function renew_subscription( $subscription ) { |
|
| 692 | + */ |
|
| 693 | + public function renew_subscription( $subscription ) { |
|
| 694 | 694 | |
| 695 | - // Generate the renewal invoice. |
|
| 696 | - $new_invoice = $subscription->create_payment(); |
|
| 697 | - $old_invoice = $subscription->get_parent_payment(); |
|
| 695 | + // Generate the renewal invoice. |
|
| 696 | + $new_invoice = $subscription->create_payment(); |
|
| 697 | + $old_invoice = $subscription->get_parent_payment(); |
|
| 698 | 698 | |
| 699 | 699 | if ( empty( $new_invoice ) ) { |
| 700 | 700 | $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
@@ -703,37 +703,37 @@ discard block |
||
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | // Charge the payment method. |
| 706 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 707 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
| 708 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
| 709 | - |
|
| 710 | - // Do we have an error? |
|
| 711 | - if ( is_wp_error( $result ) ) { |
|
| 712 | - |
|
| 713 | - $old_invoice->add_note( |
|
| 714 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
| 715 | - true, |
|
| 716 | - false, |
|
| 717 | - true |
|
| 718 | - ); |
|
| 719 | - $subscription->failing(); |
|
| 720 | - return; |
|
| 721 | - |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - // Process the response. |
|
| 725 | - $this->process_charge_response( $result, $new_invoice ); |
|
| 726 | - |
|
| 727 | - if ( wpinv_get_errors() ) { |
|
| 728 | - |
|
| 729 | - $old_invoice->add_note( |
|
| 730 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
| 731 | - true, |
|
| 732 | - false, |
|
| 733 | - true |
|
| 734 | - ); |
|
| 735 | - $subscription->failing(); |
|
| 736 | - return; |
|
| 706 | + $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 707 | + $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
| 708 | + $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
| 709 | + |
|
| 710 | + // Do we have an error? |
|
| 711 | + if ( is_wp_error( $result ) ) { |
|
| 712 | + |
|
| 713 | + $old_invoice->add_note( |
|
| 714 | + sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
| 715 | + true, |
|
| 716 | + false, |
|
| 717 | + true |
|
| 718 | + ); |
|
| 719 | + $subscription->failing(); |
|
| 720 | + return; |
|
| 721 | + |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + // Process the response. |
|
| 725 | + $this->process_charge_response( $result, $new_invoice ); |
|
| 726 | + |
|
| 727 | + if ( wpinv_get_errors() ) { |
|
| 728 | + |
|
| 729 | + $old_invoice->add_note( |
|
| 730 | + sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
| 731 | + true, |
|
| 732 | + false, |
|
| 733 | + true |
|
| 734 | + ); |
|
| 735 | + $subscription->failing(); |
|
| 736 | + return; |
|
| 737 | 737 | |
| 738 | 738 | } |
| 739 | 739 | |
@@ -742,13 +742,13 @@ discard block |
||
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
| 745 | - * Processes invoice addons. |
|
| 746 | - * |
|
| 747 | - * @param WPInv_Invoice $invoice |
|
| 748 | - * @param GetPaid_Form_Item[] $items |
|
| 749 | - * @return WPInv_Invoice |
|
| 750 | - */ |
|
| 751 | - public function process_addons( $invoice, $items ) { |
|
| 745 | + * Processes invoice addons. |
|
| 746 | + * |
|
| 747 | + * @param WPInv_Invoice $invoice |
|
| 748 | + * @param GetPaid_Form_Item[] $items |
|
| 749 | + * @return WPInv_Invoice |
|
| 750 | + */ |
|
| 751 | + public function process_addons( $invoice, $items ) { |
|
| 752 | 752 | |
| 753 | 753 | global $getpaid_authorize_addons; |
| 754 | 754 | |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | $invoice->recalculate_total(); |
| 769 | 769 | |
| 770 | 770 | $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
| 771 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 771 | + $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 772 | 772 | |
| 773 | 773 | add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
| 774 | 774 | $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | - * Processes invoice addons. |
|
| 787 | - * |
|
| 786 | + * Processes invoice addons. |
|
| 787 | + * |
|
| 788 | 788 | * @param array $args |
| 789 | - * @return array |
|
| 790 | - */ |
|
| 789 | + * @return array |
|
| 790 | + */ |
|
| 791 | 791 | public function filter_addons_request( $args ) { |
| 792 | 792 | |
| 793 | 793 | global $getpaid_authorize_addons; |
@@ -821,11 +821,11 @@ discard block |
||
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | /** |
| 824 | - * Filters the gateway settings. |
|
| 825 | - * |
|
| 826 | - * @param array $admin_settings |
|
| 827 | - */ |
|
| 828 | - public function admin_settings( $admin_settings ) { |
|
| 824 | + * Filters the gateway settings. |
|
| 825 | + * |
|
| 826 | + * @param array $admin_settings |
|
| 827 | + */ |
|
| 828 | + public function admin_settings( $admin_settings ) { |
|
| 829 | 829 | |
| 830 | 830 | $currencies = sprintf( |
| 831 | 831 | __( 'Supported Currencies: %s', 'invoicing' ), |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | 'readonly' => true, |
| 866 | 866 | ); |
| 867 | 867 | |
| 868 | - return $admin_settings; |
|
| 869 | - } |
|
| 868 | + return $admin_settings; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | 871 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Authorize.net Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
| 27 | + protected $supports = array('subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @var array |
| 54 | 54 | */ |
| 55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
| 55 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * URL to view a transaction. |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function __construct() { |
| 68 | 68 | |
| 69 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
| 70 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
| 71 | - $this->notify_url = getpaid_get_non_query_string_ipn_url( $this->id ); |
|
| 69 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
| 70 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
| 71 | + $this->notify_url = getpaid_get_non_query_string_ipn_url($this->id); |
|
| 72 | 72 | |
| 73 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
| 74 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
| 73 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription')); |
|
| 74 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
| 75 | 75 | parent::__construct(); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | * @param int $invoice_id 0 or invoice id. |
| 82 | 82 | * @param GetPaid_Payment_Form $form Current payment form. |
| 83 | 83 | */ |
| 84 | - public function payment_fields( $invoice_id, $form ) { |
|
| 84 | + public function payment_fields($invoice_id, $form) { |
|
| 85 | 85 | |
| 86 | 86 | // Let the user select a payment method. |
| 87 | 87 | echo $this->saved_payment_methods(); |
| 88 | 88 | |
| 89 | 89 | // Show the credit card entry form. |
| 90 | - echo $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
| 90 | + echo $this->new_payment_method_entry($this->get_cc_form(true)); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -100,79 +100,79 @@ discard block |
||
| 100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 101 | 101 | * @return string|WP_Error Payment profile id. |
| 102 | 102 | */ |
| 103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
| 103 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
| 104 | 104 | |
| 105 | 105 | // Remove non-digits from the number |
| 106 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
| 106 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
| 107 | 107 | |
| 108 | 108 | // Generate args. |
| 109 | 109 | $args = array( |
| 110 | 110 | 'createCustomerProfileRequest' => array( |
| 111 | 111 | 'merchantAuthentication' => $this->get_auth_params(), |
| 112 | 112 | 'profile' => array( |
| 113 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
| 114 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
| 115 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
| 113 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
| 114 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
| 115 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
| 116 | 116 | 'paymentProfiles' => array( |
| 117 | 117 | 'customerType' => 'individual', |
| 118 | 118 | |
| 119 | 119 | // Billing information. |
| 120 | 120 | 'billTo' => array( |
| 121 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
| 122 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
| 123 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
| 124 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
| 125 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
| 126 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
| 127 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
| 121 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
| 122 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
| 123 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
| 124 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
| 125 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
| 126 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
| 127 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
| 128 | 128 | ), |
| 129 | 129 | |
| 130 | 130 | // Payment information. |
| 131 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
| 131 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
| 132 | 132 | ) |
| 133 | 133 | ), |
| 134 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
| 134 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
| 135 | 135 | ) |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
| 138 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
| 139 | 139 | |
| 140 | - if ( is_wp_error( $response ) ) { |
|
| 140 | + if (is_wp_error($response)) { |
|
| 141 | 141 | |
| 142 | 142 | // In case the payment profile already exists remotely. |
| 143 | - if ( 'dup_payment_profile' == $response->get_error_code() ) { |
|
| 144 | - $customer_profile_id = strtok( $response->get_error_message(), '.' ); |
|
| 145 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id ); |
|
| 146 | - return strtok( '.' ); |
|
| 143 | + if ('dup_payment_profile' == $response->get_error_code()) { |
|
| 144 | + $customer_profile_id = strtok($response->get_error_message(), '.'); |
|
| 145 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id); |
|
| 146 | + return strtok('.'); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | // In case the customer profile already exists remotely. |
| 150 | - if ( 'E00039' == $response->get_error_code() ) { |
|
| 151 | - $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() ); |
|
| 152 | - $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id ); |
|
| 153 | - return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save ); |
|
| 150 | + if ('E00039' == $response->get_error_code()) { |
|
| 151 | + $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message()); |
|
| 152 | + $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id); |
|
| 153 | + return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | return $response; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
| 159 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
| 160 | 160 | |
| 161 | 161 | // Save the payment token. |
| 162 | - if ( $save ) { |
|
| 162 | + if ($save) { |
|
| 163 | 163 | $this->save_token( |
| 164 | 164 | array( |
| 165 | 165 | 'id' => $response->customerPaymentProfileIdList[0], |
| 166 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
| 166 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
| 167 | 167 | 'default' => true, |
| 168 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
| 168 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
| 169 | 169 | ) |
| 170 | 170 | ); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Add a note about the validation response. |
| 174 | 174 | $invoice->add_note( |
| 175 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
| 175 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
| 176 | 176 | false, |
| 177 | 177 | false, |
| 178 | 178 | true |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @return string|WP_Error Profile id. |
| 190 | 190 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
| 191 | 191 | */ |
| 192 | - public function get_customer_profile( $profile_id ) { |
|
| 192 | + public function get_customer_profile($profile_id) { |
|
| 193 | 193 | |
| 194 | 194 | // Generate args. |
| 195 | 195 | $args = array( |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | ) |
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | - return $this->post( $args, false ); |
|
| 202 | + return $this->post($args, false); |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -214,18 +214,18 @@ discard block |
||
| 214 | 214 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
| 215 | 215 | * @return string|WP_Error Profile id. |
| 216 | 216 | */ |
| 217 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
| 217 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
| 218 | 218 | |
| 219 | 219 | // Remove non-digits from the number |
| 220 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
| 220 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
| 221 | 221 | |
| 222 | 222 | // Prepare card details. |
| 223 | - $payment_information = $this->get_payment_information( $submission_data['authorizenet'] ); |
|
| 223 | + $payment_information = $this->get_payment_information($submission_data['authorizenet']); |
|
| 224 | 224 | |
| 225 | 225 | // Authorize.NET does not support saving the same card twice. |
| 226 | - $cached_information = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice ); |
|
| 226 | + $cached_information = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice); |
|
| 227 | 227 | |
| 228 | - if ( $cached_information ) { |
|
| 228 | + if ($cached_information) { |
|
| 229 | 229 | return $cached_information; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -238,34 +238,34 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | // Billing information. |
| 240 | 240 | 'billTo' => array( |
| 241 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
| 242 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
| 243 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
| 244 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
| 245 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
| 246 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
| 247 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
| 241 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
| 242 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
| 243 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
| 244 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
| 245 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
| 246 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
| 247 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
| 248 | 248 | ), |
| 249 | 249 | |
| 250 | 250 | // Payment information. |
| 251 | 251 | 'payment' => $payment_information |
| 252 | 252 | ), |
| 253 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
| 253 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
| 254 | 254 | ) |
| 255 | 255 | ); |
| 256 | 256 | |
| 257 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
| 257 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
| 258 | 258 | |
| 259 | - if ( is_wp_error( $response ) ) { |
|
| 259 | + if (is_wp_error($response)) { |
|
| 260 | 260 | |
| 261 | 261 | // In case the payment profile already exists remotely. |
| 262 | - if ( 'dup_payment_profile' == $response->get_error_code() ) { |
|
| 263 | - $customer_profile_id = strtok( $response->get_error_message(), '.' ); |
|
| 264 | - $payment_profile_id = strtok( '.' ); |
|
| 265 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id ); |
|
| 262 | + if ('dup_payment_profile' == $response->get_error_code()) { |
|
| 263 | + $customer_profile_id = strtok($response->get_error_message(), '.'); |
|
| 264 | + $payment_profile_id = strtok('.'); |
|
| 265 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id); |
|
| 266 | 266 | |
| 267 | 267 | // Cache payment profile id. |
| 268 | - $this->add_payment_profile_to_cache( $payment_information, $payment_profile_id ); |
|
| 268 | + $this->add_payment_profile_to_cache($payment_information, $payment_profile_id); |
|
| 269 | 269 | |
| 270 | 270 | return $payment_profile_id; |
| 271 | 271 | } |
@@ -274,29 +274,29 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Save the payment token. |
| 277 | - if ( $save ) { |
|
| 277 | + if ($save) { |
|
| 278 | 278 | $this->save_token( |
| 279 | 279 | array( |
| 280 | 280 | 'id' => $response->customerPaymentProfileId, |
| 281 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
| 281 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
| 282 | 282 | 'default' => true, |
| 283 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
| 283 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
| 284 | 284 | ) |
| 285 | 285 | ); |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // Cache payment profile id. |
| 289 | - $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId ); |
|
| 289 | + $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId); |
|
| 290 | 290 | |
| 291 | 291 | // Add a note about the validation response. |
| 292 | 292 | $invoice->add_note( |
| 293 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
| 293 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
| 294 | 294 | false, |
| 295 | 295 | false, |
| 296 | 296 | true |
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile ); |
|
| 299 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile); |
|
| 300 | 300 | |
| 301 | 301 | return $response->customerPaymentProfileId; |
| 302 | 302 | } |
@@ -308,12 +308,12 @@ discard block |
||
| 308 | 308 | * @param array $payment_details. |
| 309 | 309 | * @return array|false Profile id. |
| 310 | 310 | */ |
| 311 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
| 311 | + public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) { |
|
| 312 | 312 | |
| 313 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
| 314 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
| 313 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
| 314 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
| 315 | 315 | |
| 316 | - if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) { |
|
| 316 | + if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) { |
|
| 317 | 317 | return false; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -322,13 +322,13 @@ discard block |
||
| 322 | 322 | 'getCustomerPaymentProfileRequest' => array( |
| 323 | 323 | 'merchantAuthentication' => $this->get_auth_params(), |
| 324 | 324 | 'customerProfileId' => $customer_profile, |
| 325 | - 'customerPaymentProfileId' => $cached_information[ $payment_details ], |
|
| 325 | + 'customerPaymentProfileId' => $cached_information[$payment_details], |
|
| 326 | 326 | ) |
| 327 | 327 | ); |
| 328 | 328 | |
| 329 | - $response = $this->post( $args, $invoice ); |
|
| 329 | + $response = $this->post($args, $invoice); |
|
| 330 | 330 | |
| 331 | - return is_wp_error( $response ) ? false : $cached_information[ $payment_details ]; |
|
| 331 | + return is_wp_error($response) ? false : $cached_information[$payment_details]; |
|
| 332 | 332 | |
| 333 | 333 | } |
| 334 | 334 | |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | * @param array $payment_details. |
| 340 | 340 | * @param string $payment_profile_id. |
| 341 | 341 | */ |
| 342 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
| 342 | + public function add_payment_profile_to_cache($payment_details, $payment_profile_id) { |
|
| 343 | 343 | |
| 344 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
| 345 | - $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
|
| 346 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
| 344 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
| 345 | + $cached_information = is_array($cached_information) ? $cached_information : array(); |
|
| 346 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
| 347 | 347 | |
| 348 | - $cached_information[ $payment_details ] = $payment_profile_id; |
|
| 349 | - update_option( 'getpaid_authorize_net_cached_profiles', $cached_information ); |
|
| 348 | + $cached_information[$payment_details] = $payment_profile_id; |
|
| 349 | + update_option('getpaid_authorize_net_cached_profiles', $cached_information); |
|
| 350 | 350 | |
| 351 | 351 | } |
| 352 | 352 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * @return string|WP_Error Profile id. |
| 360 | 360 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
| 361 | 361 | */ |
| 362 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
| 362 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
| 363 | 363 | |
| 364 | 364 | // Generate args. |
| 365 | 365 | $args = array( |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | ) |
| 371 | 371 | ); |
| 372 | 372 | |
| 373 | - return $this->post( $args, false ); |
|
| 373 | + return $this->post($args, false); |
|
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
| 384 | 384 | * @return WP_Error|object |
| 385 | 385 | */ |
| 386 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
| 386 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
| 387 | 387 | |
| 388 | 388 | // Generate args. |
| 389 | 389 | $args = array( |
@@ -403,28 +403,28 @@ discard block |
||
| 403 | 403 | ) |
| 404 | 404 | ), |
| 405 | 405 | 'order' => array( |
| 406 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
| 406 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
| 407 | 407 | ), |
| 408 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
| 408 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
| 409 | 409 | 'tax' => array( |
| 410 | 410 | 'amount' => $invoice->get_total_tax(), |
| 411 | - 'name' => __( 'TAX', 'invoicing' ), |
|
| 411 | + 'name' => __('TAX', 'invoicing'), |
|
| 412 | 412 | ), |
| 413 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
| 413 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
| 414 | 414 | 'customer' => array( |
| 415 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
| 416 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
| 415 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
| 416 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
| 417 | 417 | ), |
| 418 | 418 | 'customerIP' => $invoice->get_ip(), |
| 419 | 419 | ) |
| 420 | 420 | ) |
| 421 | 421 | ); |
| 422 | 422 | |
| 423 | - if ( 0 == $invoice->get_total_tax() ) { |
|
| 424 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
| 423 | + if (0 == $invoice->get_total_tax()) { |
|
| 424 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
| 427 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
| 428 | 428 | |
| 429 | 429 | } |
| 430 | 430 | |
@@ -434,29 +434,29 @@ discard block |
||
| 434 | 434 | * @param stdClass $result Api response. |
| 435 | 435 | * @param WPInv_Invoice $invoice Invoice. |
| 436 | 436 | */ |
| 437 | - public function process_charge_response( $result, $invoice ) { |
|
| 437 | + public function process_charge_response($result, $invoice) { |
|
| 438 | 438 | |
| 439 | 439 | wpinv_clear_errors(); |
| 440 | 440 | $response_code = (int) $result->transactionResponse->responseCode; |
| 441 | 441 | |
| 442 | 442 | // Succeeded. |
| 443 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
| 443 | + if (1 == $response_code || 4 == $response_code) { |
|
| 444 | 444 | |
| 445 | 445 | // Maybe set a transaction id. |
| 446 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
| 447 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
| 446 | + if (!empty($result->transactionResponse->transId)) { |
|
| 447 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
| 450 | + $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
| 451 | 451 | |
| 452 | - if ( 1 == $response_code ) { |
|
| 452 | + if (1 == $response_code) { |
|
| 453 | 453 | return $invoice->mark_paid(); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - $invoice->set_status( 'wpi-onhold' ); |
|
| 456 | + $invoice->set_status('wpi-onhold'); |
|
| 457 | 457 | $invoice->add_note( |
| 458 | 458 | sprintf( |
| 459 | - __( 'Held for review: %s', 'invoicing' ), |
|
| 459 | + __('Held for review: %s', 'invoicing'), |
|
| 460 | 460 | $result->transactionResponse->messages->message[0]->description |
| 461 | 461 | ) |
| 462 | 462 | ); |
@@ -465,11 +465,11 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
|
| 468 | + wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing')); |
|
| 469 | 469 | |
| 470 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
| 470 | + if (!empty($result->transactionResponse->errors)) { |
|
| 471 | 471 | $errors = (object) $result->transactionResponse->errors; |
| 472 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
| 472 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | } |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | * @param array $card Card details. |
| 482 | 482 | * @return array |
| 483 | 483 | */ |
| 484 | - public function get_payment_information( $card ) { |
|
| 484 | + public function get_payment_information($card) { |
|
| 485 | 485 | return array( |
| 486 | 486 | |
| 487 | - 'creditCard' => array ( |
|
| 487 | + 'creditCard' => array( |
|
| 488 | 488 | 'cardNumber' => $card['cc_number'], |
| 489 | 489 | 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'], |
| 490 | 490 | 'cardCode' => $card['cc_cvv2'], |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | * @param WPInv_Invoice $invoice Invoice. |
| 501 | 501 | * @return string |
| 502 | 502 | */ |
| 503 | - public function get_customer_profile_meta_name( $invoice ) { |
|
| 504 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
| 503 | + public function get_customer_profile_meta_name($invoice) { |
|
| 504 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /** |
@@ -512,34 +512,34 @@ discard block |
||
| 512 | 512 | * @param WPInv_Invoice $invoice |
| 513 | 513 | * @return WP_Error|string The payment profile id |
| 514 | 514 | */ |
| 515 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
| 515 | + public function validate_submission_data($submission_data, $invoice) { |
|
| 516 | 516 | |
| 517 | 517 | // Validate authentication details. |
| 518 | 518 | $auth = $this->get_auth_params(); |
| 519 | 519 | |
| 520 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
| 521 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') ); |
|
| 520 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
| 521 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | // Validate the payment method. |
| 525 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
| 526 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') ); |
|
| 525 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
| 526 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | // Are we adding a new payment method? |
| 530 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
| 530 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
| 531 | 531 | return $submission_data['getpaid-authorizenet-payment-method']; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // Retrieve the customer profile id. |
| 535 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 535 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
| 536 | 536 | |
| 537 | 537 | // Create payment method. |
| 538 | - if ( empty( $profile_id ) ) { |
|
| 539 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
| 538 | + if (empty($profile_id)) { |
|
| 539 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
| 542 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
| 543 | 543 | |
| 544 | 544 | } |
| 545 | 545 | |
@@ -550,32 +550,32 @@ discard block |
||
| 550 | 550 | * @param WPInv_Invoice $invoice Invoice. |
| 551 | 551 | * @return array |
| 552 | 552 | */ |
| 553 | - public function get_line_items( $invoice ) { |
|
| 553 | + public function get_line_items($invoice) { |
|
| 554 | 554 | $items = array(); |
| 555 | 555 | |
| 556 | - foreach ( $invoice->get_items() as $item ) { |
|
| 556 | + foreach ($invoice->get_items() as $item) { |
|
| 557 | 557 | |
| 558 | 558 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
| 559 | 559 | $items[] = array( |
| 560 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
| 561 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
| 562 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
| 563 | - 'quantity' => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ), |
|
| 560 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
| 561 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
| 562 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
| 563 | + 'quantity' => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()), |
|
| 564 | 564 | 'unitPrice' => (float) $amount, |
| 565 | 565 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
| 566 | 566 | ); |
| 567 | 567 | |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
| 570 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
| 571 | 571 | |
| 572 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
| 572 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
| 573 | 573 | |
| 574 | - if ( $amount > 0 ) { |
|
| 574 | + if ($amount > 0) { |
|
| 575 | 575 | $items[] = array( |
| 576 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
| 577 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
| 578 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
| 576 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
| 577 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
| 578 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
| 579 | 579 | 'quantity' => '1', |
| 580 | 580 | 'unitPrice' => (float) $amount, |
| 581 | 581 | 'taxable' => false, |
@@ -596,36 +596,36 @@ discard block |
||
| 596 | 596 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 597 | 597 | * @return array |
| 598 | 598 | */ |
| 599 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 599 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 600 | 600 | |
| 601 | 601 | // Validate the submitted data. |
| 602 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
| 602 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
| 603 | 603 | |
| 604 | 604 | // Do we have an error? |
| 605 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
| 606 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
| 607 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 605 | + if (is_wp_error($payment_profile_id)) { |
|
| 606 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
| 607 | + wpinv_send_back_to_checkout($invoice); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | // Save the payment method to the order. |
| 611 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
| 611 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
| 612 | 612 | |
| 613 | 613 | // Check if this is a subscription or not. |
| 614 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 615 | - if ( ! empty( $subscriptions ) ) { |
|
| 616 | - $this->process_subscription( $invoice, $subscriptions ); |
|
| 614 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 615 | + if (!empty($subscriptions)) { |
|
| 616 | + $this->process_subscription($invoice, $subscriptions); |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | // If it is free, send to the success page. |
| 620 | - if ( ! $invoice->needs_payment() ) { |
|
| 620 | + if (!$invoice->needs_payment()) { |
|
| 621 | 621 | $invoice->mark_paid(); |
| 622 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 622 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | // Charge the payment profile. |
| 626 | - $this->process_initial_payment( $invoice ); |
|
| 626 | + $this->process_initial_payment($invoice); |
|
| 627 | 627 | |
| 628 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 628 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 629 | 629 | |
| 630 | 630 | exit; |
| 631 | 631 | |
@@ -636,23 +636,23 @@ discard block |
||
| 636 | 636 | * |
| 637 | 637 | * @param WPInv_Invoice $invoice Invoice. |
| 638 | 638 | */ |
| 639 | - protected function process_initial_payment( $invoice ) { |
|
| 639 | + protected function process_initial_payment($invoice) { |
|
| 640 | 640 | |
| 641 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 642 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 643 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 641 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
| 642 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
| 643 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
| 644 | 644 | |
| 645 | 645 | // Do we have an error? |
| 646 | - if ( is_wp_error( $result ) ) { |
|
| 647 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 648 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 646 | + if (is_wp_error($result)) { |
|
| 647 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
| 648 | + wpinv_send_back_to_checkout($invoice); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | // Process the response. |
| 652 | - $this->process_charge_response( $result, $invoice ); |
|
| 652 | + $this->process_charge_response($result, $invoice); |
|
| 653 | 653 | |
| 654 | - if ( wpinv_get_errors() ) { |
|
| 655 | - wpinv_send_back_to_checkout( $invoice ); |
|
| 654 | + if (wpinv_get_errors()) { |
|
| 655 | + wpinv_send_back_to_checkout($invoice); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | } |
@@ -663,30 +663,30 @@ discard block |
||
| 663 | 663 | * @param WPInv_Invoice $invoice Invoice. |
| 664 | 664 | * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions. |
| 665 | 665 | */ |
| 666 | - public function process_subscription( $invoice, $subscriptions ) { |
|
| 666 | + public function process_subscription($invoice, $subscriptions) { |
|
| 667 | 667 | |
| 668 | 668 | // Check if there is an initial amount to charge. |
| 669 | - if ( (float) $invoice->get_total() > 0 ) { |
|
| 670 | - $this->process_initial_payment( $invoice ); |
|
| 669 | + if ((float) $invoice->get_total() > 0) { |
|
| 670 | + $this->process_initial_payment($invoice); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | // Activate the subscriptions. |
| 674 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
| 674 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
| 675 | 675 | |
| 676 | - foreach ( $subscriptions as $subscription ) { |
|
| 677 | - if ( $subscription->exists() ) { |
|
| 678 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
| 679 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
| 676 | + foreach ($subscriptions as $subscription) { |
|
| 677 | + if ($subscription->exists()) { |
|
| 678 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
| 679 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
| 680 | 680 | |
| 681 | - $subscription->set_next_renewal_date( $expiry ); |
|
| 682 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 683 | - $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
| 681 | + $subscription->set_next_renewal_date($expiry); |
|
| 682 | + $subscription->set_date_created(current_time('mysql')); |
|
| 683 | + $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
| 684 | 684 | $subscription->activate(); |
| 685 | 685 | } |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | // Redirect to the success page. |
| 689 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 689 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 690 | 690 | |
| 691 | 691 | } |
| 692 | 692 | |
@@ -696,11 +696,11 @@ discard block |
||
| 696 | 696 | * |
| 697 | 697 | * @param WPInv_Subscription $subscription |
| 698 | 698 | */ |
| 699 | - public function maybe_renew_subscription( $subscription ) { |
|
| 699 | + public function maybe_renew_subscription($subscription) { |
|
| 700 | 700 | |
| 701 | 701 | // Ensure its our subscription && it's active. |
| 702 | - if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
| 703 | - $this->renew_subscription( $subscription ); |
|
| 702 | + if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) { |
|
| 703 | + $this->renew_subscription($subscription); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | } |
@@ -710,28 +710,28 @@ discard block |
||
| 710 | 710 | * |
| 711 | 711 | * @param WPInv_Subscription $subscription |
| 712 | 712 | */ |
| 713 | - public function renew_subscription( $subscription ) { |
|
| 713 | + public function renew_subscription($subscription) { |
|
| 714 | 714 | |
| 715 | 715 | // Generate the renewal invoice. |
| 716 | 716 | $new_invoice = $subscription->create_payment(); |
| 717 | 717 | $old_invoice = $subscription->get_parent_payment(); |
| 718 | 718 | |
| 719 | - if ( empty( $new_invoice ) ) { |
|
| 720 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
| 719 | + if (empty($new_invoice)) { |
|
| 720 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
| 721 | 721 | $subscription->failing(); |
| 722 | 722 | return; |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | // Charge the payment method. |
| 726 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 727 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
| 728 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
| 726 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
| 727 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
| 728 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
| 729 | 729 | |
| 730 | 730 | // Do we have an error? |
| 731 | - if ( is_wp_error( $result ) ) { |
|
| 731 | + if (is_wp_error($result)) { |
|
| 732 | 732 | |
| 733 | 733 | $old_invoice->add_note( |
| 734 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
| 734 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
| 735 | 735 | true, |
| 736 | 736 | false, |
| 737 | 737 | true |
@@ -742,12 +742,12 @@ discard block |
||
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | // Process the response. |
| 745 | - $this->process_charge_response( $result, $new_invoice ); |
|
| 745 | + $this->process_charge_response($result, $new_invoice); |
|
| 746 | 746 | |
| 747 | - if ( wpinv_get_errors() ) { |
|
| 747 | + if (wpinv_get_errors()) { |
|
| 748 | 748 | |
| 749 | 749 | $old_invoice->add_note( |
| 750 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
| 750 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
| 751 | 751 | true, |
| 752 | 752 | false, |
| 753 | 753 | true |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - $subscription->add_payment( array(), $new_invoice ); |
|
| 760 | + $subscription->add_payment(array(), $new_invoice); |
|
| 761 | 761 | $subscription->renew(); |
| 762 | 762 | } |
| 763 | 763 | |
@@ -768,34 +768,34 @@ discard block |
||
| 768 | 768 | * @param GetPaid_Form_Item[] $items |
| 769 | 769 | * @return WPInv_Invoice |
| 770 | 770 | */ |
| 771 | - public function process_addons( $invoice, $items ) { |
|
| 771 | + public function process_addons($invoice, $items) { |
|
| 772 | 772 | |
| 773 | 773 | global $getpaid_authorize_addons; |
| 774 | 774 | |
| 775 | 775 | $getpaid_authorize_addons = array(); |
| 776 | - foreach ( $items as $item ) { |
|
| 776 | + foreach ($items as $item) { |
|
| 777 | 777 | |
| 778 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
| 778 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
| 779 | 779 | $getpaid_authorize_addons[] = $item; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
| 784 | + if (empty($getpaid_authorize_addons)) { |
|
| 785 | 785 | return; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | $invoice->recalculate_total(); |
| 789 | 789 | |
| 790 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
| 791 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
| 790 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
| 791 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
| 792 | 792 | |
| 793 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
| 794 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
| 795 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
| 793 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
| 794 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
| 795 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
| 796 | 796 | |
| 797 | - if ( is_wp_error( $result ) ) { |
|
| 798 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
| 797 | + if (is_wp_error($result)) { |
|
| 798 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
| 799 | 799 | return; |
| 800 | 800 | } |
| 801 | 801 | |
@@ -808,19 +808,19 @@ discard block |
||
| 808 | 808 | * @param array $args |
| 809 | 809 | * @return array |
| 810 | 810 | */ |
| 811 | - public function filter_addons_request( $args ) { |
|
| 811 | + public function filter_addons_request($args) { |
|
| 812 | 812 | |
| 813 | 813 | global $getpaid_authorize_addons; |
| 814 | 814 | $total = 0; |
| 815 | 815 | |
| 816 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
| 816 | + foreach ($getpaid_authorize_addons as $addon) { |
|
| 817 | 817 | $total += $addon->get_sub_total(); |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
| 821 | 821 | |
| 822 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
| 823 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
| 822 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
| 823 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | return $args; |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | public function sandbox_notice() { |
| 834 | 834 | |
| 835 | 835 | return sprintf( |
| 836 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 836 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
| 837 | 837 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
| 838 | 838 | '</a>' |
| 839 | 839 | ); |
@@ -845,42 +845,42 @@ discard block |
||
| 845 | 845 | * |
| 846 | 846 | * @param array $admin_settings |
| 847 | 847 | */ |
| 848 | - public function admin_settings( $admin_settings ) { |
|
| 848 | + public function admin_settings($admin_settings) { |
|
| 849 | 849 | |
| 850 | 850 | $currencies = sprintf( |
| 851 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
| 852 | - implode( ', ', $this->currencies ) |
|
| 851 | + __('Supported Currencies: %s', 'invoicing'), |
|
| 852 | + implode(', ', $this->currencies) |
|
| 853 | 853 | ); |
| 854 | 854 | |
| 855 | 855 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
| 856 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
| 856 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
| 857 | 857 | |
| 858 | 858 | $admin_settings['authorizenet_login_id'] = array( |
| 859 | 859 | 'type' => 'text', |
| 860 | 860 | 'id' => 'authorizenet_login_id', |
| 861 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
| 862 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
| 861 | + 'name' => __('API Login ID', 'invoicing'), |
|
| 862 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
| 863 | 863 | ); |
| 864 | 864 | |
| 865 | 865 | $admin_settings['authorizenet_transaction_key'] = array( |
| 866 | 866 | 'type' => 'text', |
| 867 | 867 | 'id' => 'authorizenet_transaction_key', |
| 868 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
| 868 | + 'name' => __('Transaction Key', 'invoicing'), |
|
| 869 | 869 | ); |
| 870 | 870 | |
| 871 | 871 | $admin_settings['authorizenet_signature_key'] = array( |
| 872 | 872 | 'type' => 'text', |
| 873 | 873 | 'id' => 'authorizenet_signature_key', |
| 874 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
| 875 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
| 874 | + 'name' => __('Signature Key', 'invoicing'), |
|
| 875 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
| 876 | 876 | ); |
| 877 | 877 | |
| 878 | 878 | $admin_settings['authorizenet_ipn_url'] = array( |
| 879 | 879 | 'type' => 'ipn_url', |
| 880 | 880 | 'id' => 'authorizenet_ipn_url', |
| 881 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
| 881 | + 'name' => __('Webhook URL', 'invoicing'), |
|
| 882 | 882 | 'std' => $this->notify_url, |
| 883 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
| 883 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
| 884 | 884 | 'custom' => 'authorizenet', |
| 885 | 885 | 'readonly' => true, |
| 886 | 886 | ); |
@@ -8,211 +8,211 @@ discard block |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $getpaid_pages = GetPaid_Installer::get_pages(); |
| 14 | -$pages = wpinv_get_pages( true ); |
|
| 14 | +$pages = wpinv_get_pages(true); |
|
| 15 | 15 | |
| 16 | 16 | $currencies = wpinv_get_currencies(); |
| 17 | 17 | |
| 18 | 18 | $currency_code_options = array(); |
| 19 | -foreach ( $currencies as $code => $name ) { |
|
| 20 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
| 19 | +foreach ($currencies as $code => $name) { |
|
| 20 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | $invoice_number_padd_options = array(); |
| 24 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
| 24 | +for ($i = 0; $i <= 20; $i++) { |
|
| 25 | 25 | $invoice_number_padd_options[$i] = $i; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | $currency_symbol = wpinv_currency_symbol(); |
| 29 | 29 | |
| 30 | 30 | $last_number = $reset_number = ''; |
| 31 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
| 32 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
| 31 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
| 32 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
| 33 | 33 | |
| 34 | - if ( !empty( $last_invoice_number ) ) { |
|
| 35 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
| 34 | + if (!empty($last_invoice_number)) { |
|
| 35 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $nonce = wp_create_nonce('reset_invoice_count'); |
| 39 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
| 39 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $alert_wrapper_start = '<p style="color: #F00">'; |
| 43 | 43 | $alert_wrapper_close = '</p>'; |
| 44 | 44 | |
| 45 | 45 | return array( |
| 46 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
| 46 | + 'general' => apply_filters('wpinv_settings_general', |
|
| 47 | 47 | array( |
| 48 | 48 | 'main' => array( |
| 49 | 49 | 'location_settings' => array( |
| 50 | 50 | 'id' => 'location_settings', |
| 51 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
| 51 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
| 52 | 52 | 'desc' => '', |
| 53 | 53 | 'type' => 'header', |
| 54 | 54 | ), |
| 55 | 55 | 'default_country' => array( |
| 56 | 56 | 'id' => 'default_country', |
| 57 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
| 58 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
| 57 | + 'name' => __('Default Country', 'invoicing'), |
|
| 58 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
| 59 | 59 | 'type' => 'select', |
| 60 | 60 | 'options' => wpinv_get_country_list(), |
| 61 | 61 | 'std' => 'GB', |
| 62 | 62 | 'class' => 'wpi_select2', |
| 63 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
| 63 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
| 64 | 64 | ), |
| 65 | 65 | 'default_state' => array( |
| 66 | 66 | 'id' => 'default_state', |
| 67 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
| 68 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
| 67 | + 'name' => __('Default State / Province', 'invoicing'), |
|
| 68 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
| 69 | 69 | 'type' => 'country_states', |
| 70 | 70 | 'class' => 'wpi_select2', |
| 71 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 71 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 72 | 72 | ), |
| 73 | 73 | 'store_name' => array( |
| 74 | 74 | 'id' => 'store_name', |
| 75 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
| 76 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
| 75 | + 'name' => __('Store Name', 'invoicing'), |
|
| 76 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
| 77 | 77 | 'std' => get_option('blogname'), |
| 78 | 78 | 'type' => 'text', |
| 79 | 79 | ), |
| 80 | 80 | 'logo' => array( |
| 81 | 81 | 'id' => 'logo', |
| 82 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
| 83 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
| 82 | + 'name' => __('Logo URL', 'invoicing'), |
|
| 83 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
| 84 | 84 | 'type' => 'text', |
| 85 | 85 | ), |
| 86 | 86 | 'logo_width' => array( |
| 87 | 87 | 'id' => 'logo_width', |
| 88 | - 'name' => __( 'Logo width', 'invoicing' ), |
|
| 89 | - 'desc' => __( 'Logo width to use in invoice image.', 'invoicing' ), |
|
| 88 | + 'name' => __('Logo width', 'invoicing'), |
|
| 89 | + 'desc' => __('Logo width to use in invoice image.', 'invoicing'), |
|
| 90 | 90 | 'type' => 'number', |
| 91 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
| 91 | + 'placeholder' => __('Auto', 'invoicing'), |
|
| 92 | 92 | ), |
| 93 | 93 | 'logo_height' => array( |
| 94 | 94 | 'id' => 'logo_height', |
| 95 | - 'name' => __( 'Logo height', 'invoicing' ), |
|
| 96 | - 'desc' => __( 'Logo height to use in invoice image.', 'invoicing' ), |
|
| 95 | + 'name' => __('Logo height', 'invoicing'), |
|
| 96 | + 'desc' => __('Logo height to use in invoice image.', 'invoicing'), |
|
| 97 | 97 | 'type' => 'number', |
| 98 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
| 98 | + 'placeholder' => __('Auto', 'invoicing'), |
|
| 99 | 99 | ), |
| 100 | 100 | 'store_address' => array( |
| 101 | 101 | 'id' => 'store_address', |
| 102 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
| 103 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
| 102 | + 'name' => __('Store Address', 'invoicing'), |
|
| 103 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
| 104 | 104 | 'type' => 'textarea', |
| 105 | 105 | ), |
| 106 | 106 | 'page_settings' => array( |
| 107 | 107 | 'id' => 'page_settings', |
| 108 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
| 108 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
| 109 | 109 | 'desc' => '', |
| 110 | 110 | 'type' => 'header', |
| 111 | 111 | ), |
| 112 | 112 | 'checkout_page' => array( |
| 113 | 113 | 'id' => 'checkout_page', |
| 114 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
| 115 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
| 114 | + 'name' => __('Checkout Page', 'invoicing'), |
|
| 115 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
| 116 | 116 | 'type' => 'select', |
| 117 | 117 | 'options' => $pages, |
| 118 | 118 | 'class' => 'wpi_select2', |
| 119 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 120 | - 'default_content' => empty( $getpaid_pages['checkout_page'] ) ? '' : $getpaid_pages['checkout_page']['content'], |
|
| 119 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 120 | + 'default_content' => empty($getpaid_pages['checkout_page']) ? '' : $getpaid_pages['checkout_page']['content'], |
|
| 121 | 121 | 'help-tip' => true, |
| 122 | 122 | ), |
| 123 | 123 | 'success_page' => array( |
| 124 | 124 | 'id' => 'success_page', |
| 125 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
| 126 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
| 125 | + 'name' => __('Success Page', 'invoicing'), |
|
| 126 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
| 127 | 127 | 'type' => 'select', |
| 128 | 128 | 'options' => $pages, |
| 129 | 129 | 'class' => 'wpi_select2', |
| 130 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 131 | - 'default_content' => empty( $getpaid_pages['success_page'] ) ? '' : $getpaid_pages['success_page']['content'], |
|
| 130 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 131 | + 'default_content' => empty($getpaid_pages['success_page']) ? '' : $getpaid_pages['success_page']['content'], |
|
| 132 | 132 | 'help-tip' => true, |
| 133 | 133 | ), |
| 134 | 134 | 'failure_page' => array( |
| 135 | 135 | 'id' => 'failure_page', |
| 136 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
| 137 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
| 136 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
| 137 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
| 138 | 138 | 'type' => 'select', |
| 139 | 139 | 'options' => $pages, |
| 140 | 140 | 'class' => 'wpi_select2', |
| 141 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 142 | - 'default_content' => empty( $getpaid_pages['failure_page'] ) ? '' : $getpaid_pages['failure_page']['content'], |
|
| 141 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 142 | + 'default_content' => empty($getpaid_pages['failure_page']) ? '' : $getpaid_pages['failure_page']['content'], |
|
| 143 | 143 | 'help-tip' => true, |
| 144 | 144 | ), |
| 145 | 145 | 'invoice_history_page' => array( |
| 146 | 146 | 'id' => 'invoice_history_page', |
| 147 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
| 148 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
| 147 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
| 148 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
| 149 | 149 | 'type' => 'select', |
| 150 | 150 | 'options' => $pages, |
| 151 | 151 | 'class' => 'wpi_select2', |
| 152 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 153 | - 'default_content' => empty( $getpaid_pages['invoice_history_page'] ) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
| 152 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 153 | + 'default_content' => empty($getpaid_pages['invoice_history_page']) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
| 154 | 154 | 'help-tip' => true, |
| 155 | 155 | ), |
| 156 | 156 | 'invoice_subscription_page' => array( |
| 157 | 157 | 'id' => 'invoice_subscription_page', |
| 158 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
| 159 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
| 158 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
| 159 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
| 160 | 160 | 'type' => 'select', |
| 161 | 161 | 'options' => $pages, |
| 162 | 162 | 'class' => 'wpi_select2', |
| 163 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 164 | - 'default_content' => empty( $getpaid_pages['invoice_subscription_page'] ) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
| 163 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 164 | + 'default_content' => empty($getpaid_pages['invoice_subscription_page']) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
| 165 | 165 | 'help-tip' => true, |
| 166 | 166 | ), |
| 167 | 167 | ), |
| 168 | 168 | 'currency_section' => array( |
| 169 | 169 | 'currency_settings' => array( |
| 170 | 170 | 'id' => 'currency_settings', |
| 171 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
| 171 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
| 172 | 172 | 'desc' => '', |
| 173 | 173 | 'type' => 'header', |
| 174 | 174 | ), |
| 175 | 175 | 'currency' => array( |
| 176 | 176 | 'id' => 'currency', |
| 177 | - 'name' => __( 'Currency', 'invoicing' ), |
|
| 178 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
| 177 | + 'name' => __('Currency', 'invoicing'), |
|
| 178 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
| 179 | 179 | 'type' => 'select', |
| 180 | 180 | 'class' => 'wpi_select2', |
| 181 | 181 | 'options' => $currency_code_options, |
| 182 | 182 | ), |
| 183 | 183 | 'currency_position' => array( |
| 184 | 184 | 'id' => 'currency_position', |
| 185 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
| 186 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
| 185 | + 'name' => __('Currency Position', 'invoicing'), |
|
| 186 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
| 187 | 187 | 'type' => 'select', |
| 188 | 188 | 'class' => 'wpi_select2', |
| 189 | 189 | 'options' => array( |
| 190 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
| 191 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
| 192 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
| 193 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
| 190 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
| 191 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
| 192 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
| 193 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
| 194 | 194 | ) |
| 195 | 195 | ), |
| 196 | 196 | 'thousands_separator' => array( |
| 197 | 197 | 'id' => 'thousands_separator', |
| 198 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
| 199 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
| 198 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
| 199 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
| 200 | 200 | 'type' => 'text', |
| 201 | 201 | 'size' => 'small', |
| 202 | 202 | 'std' => ',', |
| 203 | 203 | ), |
| 204 | 204 | 'decimal_separator' => array( |
| 205 | 205 | 'id' => 'decimal_separator', |
| 206 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
| 207 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
| 206 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
| 207 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
| 208 | 208 | 'type' => 'text', |
| 209 | 209 | 'size' => 'small', |
| 210 | 210 | 'std' => '.', |
| 211 | 211 | ), |
| 212 | 212 | 'decimals' => array( |
| 213 | 213 | 'id' => 'decimals', |
| 214 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
| 215 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
| 214 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
| 215 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
| 216 | 216 | 'type' => 'number', |
| 217 | 217 | 'size' => 'small', |
| 218 | 218 | 'std' => '2', |
@@ -224,21 +224,21 @@ discard block |
||
| 224 | 224 | 'labels' => array( |
| 225 | 225 | 'labels' => array( |
| 226 | 226 | 'id' => 'labels_settings', |
| 227 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
| 227 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
| 228 | 228 | 'desc' => '', |
| 229 | 229 | 'type' => 'header', |
| 230 | 230 | ), |
| 231 | 231 | 'vat_invoice_notice_label' => array( |
| 232 | 232 | 'id' => 'vat_invoice_notice_label', |
| 233 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
| 234 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
| 233 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
| 234 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
| 235 | 235 | 'type' => 'text', |
| 236 | 236 | 'size' => 'regular', |
| 237 | 237 | ), |
| 238 | 238 | 'vat_invoice_notice' => array( |
| 239 | 239 | 'id' => 'vat_invoice_notice', |
| 240 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
| 241 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
| 240 | + 'name' => __('Invoice notice', 'invoicing'), |
|
| 241 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
| 242 | 242 | 'type' => 'text', |
| 243 | 243 | 'size' => 'regular', |
| 244 | 244 | ), |
@@ -250,22 +250,22 @@ discard block |
||
| 250 | 250 | 'main' => array( |
| 251 | 251 | 'gateway_settings' => array( |
| 252 | 252 | 'id' => 'api_header', |
| 253 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
| 253 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
| 254 | 254 | 'desc' => '', |
| 255 | 255 | 'type' => 'header', |
| 256 | 256 | ), |
| 257 | 257 | 'gateways' => array( |
| 258 | 258 | 'id' => 'gateways', |
| 259 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 260 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
| 259 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
| 260 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
| 261 | 261 | 'type' => 'gateways', |
| 262 | - 'std' => array( 'manual'=>1 ), |
|
| 262 | + 'std' => array('manual'=>1), |
|
| 263 | 263 | 'options' => wpinv_get_payment_gateways(), |
| 264 | 264 | ), |
| 265 | 265 | 'default_gateway' => array( |
| 266 | 266 | 'id' => 'default_gateway', |
| 267 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
| 268 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
| 267 | + 'name' => __('Default Gateway', 'invoicing'), |
|
| 268 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
| 269 | 269 | 'type' => 'gateway_select', |
| 270 | 270 | 'std' => 'manual', |
| 271 | 271 | 'class' => 'wpi_select2', |
@@ -280,32 +280,32 @@ discard block |
||
| 280 | 280 | 'main' => array( |
| 281 | 281 | 'tax_settings' => array( |
| 282 | 282 | 'id' => 'tax_settings', |
| 283 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
| 283 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
| 284 | 284 | 'type' => 'header', |
| 285 | 285 | ), |
| 286 | 286 | |
| 287 | 287 | 'enable_taxes' => array( |
| 288 | 288 | 'id' => 'enable_taxes', |
| 289 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
| 290 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
| 289 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
| 290 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
| 291 | 291 | 'type' => 'checkbox', |
| 292 | 292 | 'std' => 0, |
| 293 | 293 | ), |
| 294 | 294 | |
| 295 | 295 | 'tax_subtotal_rounding' => array( |
| 296 | 296 | 'id' => 'tax_subtotal_rounding', |
| 297 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
| 298 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
| 297 | + 'name' => __('Rounding', 'invoicing'), |
|
| 298 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
| 299 | 299 | 'type' => 'checkbox', |
| 300 | 300 | 'std' => 1, |
| 301 | 301 | ), |
| 302 | 302 | |
| 303 | 303 | 'prices_include_tax' => array( |
| 304 | 304 | 'id' => 'prices_include_tax', |
| 305 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
| 305 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
| 306 | 306 | 'options' => array( |
| 307 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
| 308 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
| 307 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
| 308 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
| 309 | 309 | ), |
| 310 | 310 | 'type' => 'select', |
| 311 | 311 | 'std' => 'no', |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | 'tax_base' => array( |
| 315 | 315 | 'id' => 'tax_base', |
| 316 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
| 316 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
| 317 | 317 | 'options' => array( |
| 318 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
| 319 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
| 318 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
| 319 | + 'base' => __('Shop base address', 'invoicing'), |
|
| 320 | 320 | ), |
| 321 | 321 | 'type' => 'select', |
| 322 | 322 | 'std' => 'billing', |
@@ -324,10 +324,10 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | 'tax_display_totals' => array( |
| 326 | 326 | 'id' => 'tax_display_totals', |
| 327 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
| 327 | + 'name' => __('Display tax totals', 'invoicing'), |
|
| 328 | 328 | 'options' => array( |
| 329 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
| 330 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
| 329 | + 'single' => __('As a single total', 'invoicing'), |
|
| 330 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
| 331 | 331 | ), |
| 332 | 332 | 'type' => 'select', |
| 333 | 333 | 'std' => 'individual', |
@@ -335,8 +335,8 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | 'tax_rate' => array( |
| 337 | 337 | 'id' => 'tax_rate', |
| 338 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
| 339 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
| 338 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
| 339 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
| 340 | 340 | 'type' => 'number', |
| 341 | 341 | 'size' => 'small', |
| 342 | 342 | 'min' => '0', |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | 'rates' => array( |
| 349 | 349 | 'tax_rates' => array( |
| 350 | 350 | 'id' => 'tax_rates', |
| 351 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
| 352 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
| 351 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
| 352 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
| 353 | 353 | 'type' => 'tax_rates', |
| 354 | 354 | ), |
| 355 | 355 | ), |
@@ -358,45 +358,45 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | 'vat_company_name' => array( |
| 360 | 360 | 'id' => 'vat_company_name', |
| 361 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
| 362 | - 'desc' => wp_sprintf(__( 'Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 361 | + 'name' => __('Company Name', 'invoicing'), |
|
| 362 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 363 | 363 | 'type' => 'text', |
| 364 | 364 | 'size' => 'regular', |
| 365 | 365 | ), |
| 366 | 366 | |
| 367 | 367 | 'vat_number' => array( |
| 368 | 368 | 'id' => 'vat_number', |
| 369 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
| 370 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
| 369 | + 'name' => __('VAT Number', 'invoicing'), |
|
| 370 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
| 371 | 371 | 'type' => 'text', |
| 372 | 372 | 'size' => 'regular', |
| 373 | 373 | ), |
| 374 | 374 | |
| 375 | 375 | 'vat_prevent_b2c_purchase' => array( |
| 376 | 376 | 'id' => 'vat_prevent_b2c_purchase', |
| 377 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
| 378 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
| 377 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
| 378 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
| 379 | 379 | 'type' => 'checkbox' |
| 380 | 380 | ), |
| 381 | 381 | |
| 382 | 382 | 'validate_vat_number' => array( |
| 383 | 383 | 'id' => 'validate_vat_number', |
| 384 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
| 385 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
| 384 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
| 385 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
| 386 | 386 | 'type' => 'checkbox' |
| 387 | 387 | ), |
| 388 | 388 | |
| 389 | 389 | 'vat_same_country_rule' => array( |
| 390 | 390 | 'id' => 'vat_same_country_rule', |
| 391 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
| 392 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
| 391 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
| 392 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
| 393 | 393 | 'type' => 'select', |
| 394 | 394 | 'options' => array( |
| 395 | - 'no' => __( 'Do not charge tax', 'invoicing' ), |
|
| 396 | - 'always' => __( 'Charge tax unless vat number is validated', 'invoicing' ), |
|
| 397 | - 'vat_too' => __( 'Charge tax even if vat number is validated', 'invoicing' ) |
|
| 395 | + 'no' => __('Do not charge tax', 'invoicing'), |
|
| 396 | + 'always' => __('Charge tax unless vat number is validated', 'invoicing'), |
|
| 397 | + 'vat_too' => __('Charge tax even if vat number is validated', 'invoicing') |
|
| 398 | 398 | ), |
| 399 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
| 399 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
| 400 | 400 | 'std' => 'vat_too', |
| 401 | 401 | ), |
| 402 | 402 | |
@@ -410,66 +410,66 @@ discard block |
||
| 410 | 410 | 'main' => array( |
| 411 | 411 | 'email_settings_header' => array( |
| 412 | 412 | 'id' => 'email_settings_header', |
| 413 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
| 413 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
| 414 | 414 | 'type' => 'header', |
| 415 | 415 | ), |
| 416 | 416 | 'email_from_name' => array( |
| 417 | 417 | 'id' => 'email_from_name', |
| 418 | - 'name' => __( 'From Name', 'invoicing' ), |
|
| 419 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
| 420 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
| 418 | + 'name' => __('From Name', 'invoicing'), |
|
| 419 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
| 420 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
| 421 | 421 | 'type' => 'text', |
| 422 | 422 | ), |
| 423 | 423 | 'email_from' => array( |
| 424 | 424 | 'id' => 'email_from', |
| 425 | - 'name' => __( 'From Email', 'invoicing' ), |
|
| 426 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
| 427 | - 'std' => get_option( 'admin_email' ), |
|
| 425 | + 'name' => __('From Email', 'invoicing'), |
|
| 426 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
| 427 | + 'std' => get_option('admin_email'), |
|
| 428 | 428 | 'type' => 'text', |
| 429 | 429 | ), |
| 430 | 430 | 'admin_email' => array( |
| 431 | 431 | 'id' => 'admin_email', |
| 432 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
| 433 | - 'desc' => __( 'Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing' ), |
|
| 434 | - 'std' => get_option( 'admin_email' ), |
|
| 432 | + 'name' => __('Admin Email', 'invoicing'), |
|
| 433 | + 'desc' => __('Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing'), |
|
| 434 | + 'std' => get_option('admin_email'), |
|
| 435 | 435 | 'type' => 'text', |
| 436 | 436 | ), |
| 437 | 437 | 'skip_email_free_invoice' => array( |
| 438 | 438 | 'id' => 'skip_email_free_invoice', |
| 439 | - 'name' => __( 'Skip Free Invoices', 'invoicing' ), |
|
| 440 | - 'desc' => __( 'Check this to disable sending emails for free invoices.', 'invoicing' ), |
|
| 439 | + 'name' => __('Skip Free Invoices', 'invoicing'), |
|
| 440 | + 'desc' => __('Check this to disable sending emails for free invoices.', 'invoicing'), |
|
| 441 | 441 | 'type' => 'checkbox', |
| 442 | 442 | 'std' => false, |
| 443 | 443 | ), |
| 444 | 444 | 'overdue_settings_header' => array( |
| 445 | 445 | 'id' => 'overdue_settings_header', |
| 446 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
| 446 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
| 447 | 447 | 'type' => 'header', |
| 448 | 448 | ), |
| 449 | 449 | 'overdue_active' => array( |
| 450 | 450 | 'id' => 'overdue_active', |
| 451 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
| 452 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
| 451 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
| 452 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
| 453 | 453 | 'type' => 'checkbox', |
| 454 | 454 | 'std' => false, |
| 455 | 455 | ), |
| 456 | 456 | 'email_template_header' => array( |
| 457 | 457 | 'id' => 'email_template_header', |
| 458 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
| 458 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
| 459 | 459 | 'type' => 'header', |
| 460 | 460 | ), |
| 461 | 461 | 'email_header_image' => array( |
| 462 | 462 | 'id' => 'email_header_image', |
| 463 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
| 464 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
| 463 | + 'name' => __('Header Image', 'invoicing'), |
|
| 464 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
| 465 | 465 | 'std' => '', |
| 466 | 466 | 'type' => 'text', |
| 467 | 467 | ), |
| 468 | 468 | 'email_footer_text' => array( |
| 469 | 469 | 'id' => 'email_footer_text', |
| 470 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
| 471 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
| 472 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ), |
|
| 470 | + 'name' => __('Footer Text', 'invoicing'), |
|
| 471 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
| 472 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'), |
|
| 473 | 473 | 'type' => 'textarea', |
| 474 | 474 | 'class' => 'regular-text', |
| 475 | 475 | 'rows' => 2, |
@@ -477,29 +477,29 @@ discard block |
||
| 477 | 477 | ), |
| 478 | 478 | 'email_base_color' => array( |
| 479 | 479 | 'id' => 'email_base_color', |
| 480 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
| 481 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
| 480 | + 'name' => __('Base Color', 'invoicing'), |
|
| 481 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
| 482 | 482 | 'std' => '#557da2', |
| 483 | 483 | 'type' => 'color', |
| 484 | 484 | ), |
| 485 | 485 | 'email_background_color' => array( |
| 486 | 486 | 'id' => 'email_background_color', |
| 487 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
| 488 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
| 487 | + 'name' => __('Background Color', 'invoicing'), |
|
| 488 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
| 489 | 489 | 'std' => '#f5f5f5', |
| 490 | 490 | 'type' => 'color', |
| 491 | 491 | ), |
| 492 | 492 | 'email_body_background_color' => array( |
| 493 | 493 | 'id' => 'email_body_background_color', |
| 494 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
| 495 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
| 494 | + 'name' => __('Body Background Color', 'invoicing'), |
|
| 495 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
| 496 | 496 | 'std' => '#fdfdfd', |
| 497 | 497 | 'type' => 'color', |
| 498 | 498 | ), |
| 499 | 499 | 'email_text_color' => array( |
| 500 | 500 | 'id' => 'email_text_color', |
| 501 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
| 502 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
| 501 | + 'name' => __('Body Text Color', 'invoicing'), |
|
| 502 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
| 503 | 503 | 'std' => '#505050', |
| 504 | 504 | 'type' => 'color', |
| 505 | 505 | ), |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | ), |
| 515 | 515 | |
| 516 | 516 | // Integrations. |
| 517 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ), |
|
| 517 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'), |
|
| 518 | 518 | |
| 519 | 519 | /** Privacy Settings */ |
| 520 | 520 | 'privacy' => apply_filters('wpinv_settings_privacy', |
@@ -522,17 +522,17 @@ discard block |
||
| 522 | 522 | 'main' => array( |
| 523 | 523 | 'invoicing_privacy_policy_settings' => array( |
| 524 | 524 | 'id' => 'invoicing_privacy_policy_settings', |
| 525 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
| 525 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
| 526 | 526 | 'type' => 'header', |
| 527 | 527 | ), |
| 528 | 528 | 'privacy_page' => array( |
| 529 | 529 | 'id' => 'privacy_page', |
| 530 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
| 531 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
| 530 | + 'name' => __('Privacy Page', 'invoicing'), |
|
| 531 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
| 532 | 532 | 'type' => 'select', |
| 533 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
| 533 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
| 534 | 534 | 'class' => 'wpi_select2', |
| 535 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 535 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 536 | 536 | ), |
| 537 | 537 | ), |
| 538 | 538 | ) |
@@ -543,19 +543,19 @@ discard block |
||
| 543 | 543 | 'main' => array( |
| 544 | 544 | 'invoice_number_format_settings' => array( |
| 545 | 545 | 'id' => 'invoice_number_format_settings', |
| 546 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
| 546 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
| 547 | 547 | 'type' => 'header', |
| 548 | 548 | ), |
| 549 | 549 | 'sequential_invoice_number' => array( |
| 550 | 550 | 'id' => 'sequential_invoice_number', |
| 551 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
| 552 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
| 551 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
| 552 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
| 553 | 553 | 'type' => 'checkbox', |
| 554 | 554 | ), |
| 555 | 555 | 'invoice_sequence_start' => array( |
| 556 | 556 | 'id' => 'invoice_sequence_start', |
| 557 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
| 558 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
| 557 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
| 558 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
| 559 | 559 | 'type' => 'number', |
| 560 | 560 | 'size' => 'small', |
| 561 | 561 | 'std' => '1', |
@@ -563,8 +563,8 @@ discard block |
||
| 563 | 563 | ), |
| 564 | 564 | 'invoice_number_padd' => array( |
| 565 | 565 | 'id' => 'invoice_number_padd', |
| 566 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
| 567 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
| 566 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
| 567 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
| 568 | 568 | 'type' => 'select', |
| 569 | 569 | 'options' => $invoice_number_padd_options, |
| 570 | 570 | 'std' => 5, |
@@ -572,8 +572,8 @@ discard block |
||
| 572 | 572 | ), |
| 573 | 573 | 'invoice_number_prefix' => array( |
| 574 | 574 | 'id' => 'invoice_number_prefix', |
| 575 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
| 576 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
| 575 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
| 576 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
| 577 | 577 | 'type' => 'text', |
| 578 | 578 | 'size' => 'regular', |
| 579 | 579 | 'std' => 'INV-', |
@@ -581,46 +581,46 @@ discard block |
||
| 581 | 581 | ), |
| 582 | 582 | 'invoice_number_postfix' => array( |
| 583 | 583 | 'id' => 'invoice_number_postfix', |
| 584 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
| 585 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
| 584 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
| 585 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
| 586 | 586 | 'type' => 'text', |
| 587 | 587 | 'size' => 'regular', |
| 588 | 588 | 'std' => '' |
| 589 | 589 | ), |
| 590 | 590 | 'checkout_settings' => array( |
| 591 | 591 | 'id' => 'checkout_settings', |
| 592 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
| 592 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
| 593 | 593 | 'type' => 'header', |
| 594 | 594 | ), |
| 595 | 595 | 'disable_new_user_emails' => array( |
| 596 | 596 | 'id' => 'disable_new_user_emails', |
| 597 | - 'name' => __( 'Disable new user emails', 'invoicing' ), |
|
| 598 | - 'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ), |
|
| 597 | + 'name' => __('Disable new user emails', 'invoicing'), |
|
| 598 | + 'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'), |
|
| 599 | 599 | 'type' => 'checkbox', |
| 600 | 600 | ), |
| 601 | 601 | 'login_to_checkout' => array( |
| 602 | 602 | 'id' => 'login_to_checkout', |
| 603 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
| 604 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
| 603 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
| 604 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
| 605 | 605 | 'type' => 'checkbox', |
| 606 | 606 | ), |
| 607 | 607 | 'maxmind_license_key' => array( |
| 608 | 608 | 'id' => 'maxmind_license_key', |
| 609 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
| 609 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
| 610 | 610 | 'type' => 'text', |
| 611 | 611 | 'size' => 'regular', |
| 612 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
| 612 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
| 613 | 613 | ), |
| 614 | 614 | |
| 615 | 615 | 'uninstall_settings' => array( |
| 616 | 616 | 'id' => 'uninstall_settings', |
| 617 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
| 617 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
| 618 | 618 | 'type' => 'header', |
| 619 | 619 | ), |
| 620 | 620 | 'remove_data_on_unistall' => array( |
| 621 | 621 | 'id' => 'remove_data_on_unistall', |
| 622 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
| 623 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
| 622 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
| 623 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
| 624 | 624 | 'type' => 'checkbox', |
| 625 | 625 | 'std' => '' |
| 626 | 626 | ), |
@@ -629,13 +629,13 @@ discard block |
||
| 629 | 629 | 'custom-css' => array( |
| 630 | 630 | 'css_settings' => array( |
| 631 | 631 | 'id' => 'css_settings', |
| 632 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
| 632 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
| 633 | 633 | 'type' => 'header', |
| 634 | 634 | ), |
| 635 | 635 | 'template_custom_css' => array( |
| 636 | 636 | 'id' => 'template_custom_css', |
| 637 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
| 638 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
| 637 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
| 638 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
| 639 | 639 | 'type' => 'textarea', |
| 640 | 640 | 'class'=> 'regular-text', |
| 641 | 641 | 'rows' => 10, |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | 'main' => array( |
| 650 | 650 | 'tool_settings' => array( |
| 651 | 651 | 'id' => 'tool_settings', |
| 652 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
| 653 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
| 652 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
| 653 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
| 654 | 654 | 'type' => 'tools', |
| 655 | 655 | ), |
| 656 | 656 | ), |