@@ -20,222 +20,222 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class GetPaid_Installer { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Upgrades the install. |
|
| 25 | - * |
|
| 26 | - * @param string $upgrade_from The current invoicing version. |
|
| 27 | - */ |
|
| 28 | - public function upgrade_db( $upgrade_from ) { |
|
| 29 | - |
|
| 30 | - // Save the current invoicing version. |
|
| 31 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
| 32 | - |
|
| 33 | - // Setup the invoice Custom Post Type. |
|
| 34 | - GetPaid_Post_Types::register_post_types(); |
|
| 35 | - |
|
| 36 | - // Clear the permalinks |
|
| 37 | - flush_rewrite_rules(); |
|
| 38 | - |
|
| 39 | - // Maybe create new/missing pages. |
|
| 40 | - $this->create_pages(); |
|
| 41 | - |
|
| 42 | - // Maybe re(add) admin capabilities. |
|
| 43 | - $this->add_capabilities(); |
|
| 44 | - |
|
| 45 | - // Maybe create the default payment form. |
|
| 46 | - wpinv_get_default_payment_form(); |
|
| 47 | - |
|
| 48 | - // Create any missing database tables. |
|
| 49 | - $method = "upgrade_from_$upgrade_from"; |
|
| 50 | - |
|
| 51 | - if ( method_exists( $this, $method ) ) { |
|
| 52 | - $this->$method(); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Do a fresh install. |
|
| 59 | - * |
|
| 60 | - */ |
|
| 61 | - public function upgrade_from_0() { |
|
| 62 | - $this->create_subscriptions_table(); |
|
| 63 | - $this->create_invoices_table(); |
|
| 64 | - $this->create_invoice_items_table(); |
|
| 65 | - |
|
| 66 | - // Save default tax rates. |
|
| 67 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Upgrade to 0.0.5 |
|
| 72 | - * |
|
| 73 | - */ |
|
| 74 | - public function upgrade_from_004() { |
|
| 75 | - global $wpdb; |
|
| 76 | - |
|
| 77 | - // Invoices. |
|
| 78 | - $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
| 79 | - if ( ! empty( $results ) ) { |
|
| 80 | - $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
| 81 | - |
|
| 82 | - // Clean post cache |
|
| 83 | - foreach ( $results as $row ) { |
|
| 84 | - clean_post_cache( $row->ID ); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - // Item meta key changes |
|
| 90 | - $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
|
| 91 | - $results = $wpdb->get_results( $query ); |
|
| 92 | - |
|
| 93 | - if ( ! empty( $results ) ) { |
|
| 94 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
| 95 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
| 96 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
| 97 | - |
|
| 98 | - foreach ( $results as $row ) { |
|
| 99 | - clean_post_cache( $row->post_id ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $this->upgrade_from_102(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Upgrade to 1.0.3 |
|
| 109 | - * |
|
| 110 | - */ |
|
| 111 | - public function upgrade_from_102() { |
|
| 112 | - $this->create_subscriptions_table(); |
|
| 113 | - $this->upgrade_from_118(); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Upgrade to version 2.0.0. |
|
| 118 | - * |
|
| 119 | - */ |
|
| 120 | - public function upgrade_from_118() { |
|
| 121 | - $this->create_invoices_table(); |
|
| 122 | - $this->create_invoice_items_table(); |
|
| 123 | - $this->migrate_old_invoices(); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Upgrade to version 2.0.8. |
|
| 128 | - * |
|
| 129 | - */ |
|
| 130 | - public function upgrade_from_207() { |
|
| 131 | - global $wpdb; |
|
| 132 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Give administrators the capability to manage GetPaid. |
|
| 137 | - * |
|
| 138 | - */ |
|
| 139 | - public function add_capabilities() { |
|
| 140 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Retreives GetPaid pages. |
|
| 145 | - * |
|
| 146 | - */ |
|
| 147 | - public static function get_pages() { |
|
| 148 | - |
|
| 149 | - return apply_filters( |
|
| 150 | - 'wpinv_create_pages', |
|
| 151 | - array( |
|
| 152 | - |
|
| 153 | - // Checkout page. |
|
| 154 | - 'checkout_page' => array( |
|
| 155 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
| 156 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
| 157 | - 'content' => ' |
|
| 23 | + /** |
|
| 24 | + * Upgrades the install. |
|
| 25 | + * |
|
| 26 | + * @param string $upgrade_from The current invoicing version. |
|
| 27 | + */ |
|
| 28 | + public function upgrade_db( $upgrade_from ) { |
|
| 29 | + |
|
| 30 | + // Save the current invoicing version. |
|
| 31 | + update_option( 'wpinv_version', WPINV_VERSION ); |
|
| 32 | + |
|
| 33 | + // Setup the invoice Custom Post Type. |
|
| 34 | + GetPaid_Post_Types::register_post_types(); |
|
| 35 | + |
|
| 36 | + // Clear the permalinks |
|
| 37 | + flush_rewrite_rules(); |
|
| 38 | + |
|
| 39 | + // Maybe create new/missing pages. |
|
| 40 | + $this->create_pages(); |
|
| 41 | + |
|
| 42 | + // Maybe re(add) admin capabilities. |
|
| 43 | + $this->add_capabilities(); |
|
| 44 | + |
|
| 45 | + // Maybe create the default payment form. |
|
| 46 | + wpinv_get_default_payment_form(); |
|
| 47 | + |
|
| 48 | + // Create any missing database tables. |
|
| 49 | + $method = "upgrade_from_$upgrade_from"; |
|
| 50 | + |
|
| 51 | + if ( method_exists( $this, $method ) ) { |
|
| 52 | + $this->$method(); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Do a fresh install. |
|
| 59 | + * |
|
| 60 | + */ |
|
| 61 | + public function upgrade_from_0() { |
|
| 62 | + $this->create_subscriptions_table(); |
|
| 63 | + $this->create_invoices_table(); |
|
| 64 | + $this->create_invoice_items_table(); |
|
| 65 | + |
|
| 66 | + // Save default tax rates. |
|
| 67 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Upgrade to 0.0.5 |
|
| 72 | + * |
|
| 73 | + */ |
|
| 74 | + public function upgrade_from_004() { |
|
| 75 | + global $wpdb; |
|
| 76 | + |
|
| 77 | + // Invoices. |
|
| 78 | + $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
| 79 | + if ( ! empty( $results ) ) { |
|
| 80 | + $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
| 81 | + |
|
| 82 | + // Clean post cache |
|
| 83 | + foreach ( $results as $row ) { |
|
| 84 | + clean_post_cache( $row->ID ); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + // Item meta key changes |
|
| 90 | + $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
|
| 91 | + $results = $wpdb->get_results( $query ); |
|
| 92 | + |
|
| 93 | + if ( ! empty( $results ) ) { |
|
| 94 | + $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
| 95 | + $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
| 96 | + $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
| 97 | + |
|
| 98 | + foreach ( $results as $row ) { |
|
| 99 | + clean_post_cache( $row->post_id ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + $this->upgrade_from_102(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Upgrade to 1.0.3 |
|
| 109 | + * |
|
| 110 | + */ |
|
| 111 | + public function upgrade_from_102() { |
|
| 112 | + $this->create_subscriptions_table(); |
|
| 113 | + $this->upgrade_from_118(); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Upgrade to version 2.0.0. |
|
| 118 | + * |
|
| 119 | + */ |
|
| 120 | + public function upgrade_from_118() { |
|
| 121 | + $this->create_invoices_table(); |
|
| 122 | + $this->create_invoice_items_table(); |
|
| 123 | + $this->migrate_old_invoices(); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Upgrade to version 2.0.8. |
|
| 128 | + * |
|
| 129 | + */ |
|
| 130 | + public function upgrade_from_207() { |
|
| 131 | + global $wpdb; |
|
| 132 | + $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Give administrators the capability to manage GetPaid. |
|
| 137 | + * |
|
| 138 | + */ |
|
| 139 | + public function add_capabilities() { |
|
| 140 | + $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Retreives GetPaid pages. |
|
| 145 | + * |
|
| 146 | + */ |
|
| 147 | + public static function get_pages() { |
|
| 148 | + |
|
| 149 | + return apply_filters( |
|
| 150 | + 'wpinv_create_pages', |
|
| 151 | + array( |
|
| 152 | + |
|
| 153 | + // Checkout page. |
|
| 154 | + 'checkout_page' => array( |
|
| 155 | + 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
| 156 | + 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
| 157 | + 'content' => ' |
|
| 158 | 158 | <!-- wp:shortcode --> |
| 159 | 159 | [wpinv_checkout] |
| 160 | 160 | <!-- /wp:shortcode --> |
| 161 | 161 | ', |
| 162 | - 'parent' => '', |
|
| 163 | - ), |
|
| 164 | - |
|
| 165 | - // Invoice history page. |
|
| 166 | - 'invoice_history_page' => array( |
|
| 167 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
| 168 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
| 169 | - 'content' => ' |
|
| 162 | + 'parent' => '', |
|
| 163 | + ), |
|
| 164 | + |
|
| 165 | + // Invoice history page. |
|
| 166 | + 'invoice_history_page' => array( |
|
| 167 | + 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
| 168 | + 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
| 169 | + 'content' => ' |
|
| 170 | 170 | <!-- wp:shortcode --> |
| 171 | 171 | [wpinv_history] |
| 172 | 172 | <!-- /wp:shortcode --> |
| 173 | 173 | ', |
| 174 | - 'parent' => '', |
|
| 175 | - ), |
|
| 176 | - |
|
| 177 | - // Success page content. |
|
| 178 | - 'success_page' => array( |
|
| 179 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
| 180 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
| 181 | - 'content' => ' |
|
| 174 | + 'parent' => '', |
|
| 175 | + ), |
|
| 176 | + |
|
| 177 | + // Success page content. |
|
| 178 | + 'success_page' => array( |
|
| 179 | + 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
| 180 | + 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
| 181 | + 'content' => ' |
|
| 182 | 182 | <!-- wp:shortcode --> |
| 183 | 183 | [wpinv_receipt] |
| 184 | 184 | <!-- /wp:shortcode --> |
| 185 | 185 | ', |
| 186 | - 'parent' => 'gp-checkout', |
|
| 187 | - ), |
|
| 188 | - |
|
| 189 | - // Failure page content. |
|
| 190 | - 'failure_page' => array( |
|
| 191 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
| 192 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
| 193 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 194 | - 'parent' => 'gp-checkout', |
|
| 195 | - ), |
|
| 196 | - |
|
| 197 | - // Subscriptions history page. |
|
| 198 | - 'invoice_subscription_page' => array( |
|
| 199 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
| 200 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
| 201 | - 'content' => ' |
|
| 186 | + 'parent' => 'gp-checkout', |
|
| 187 | + ), |
|
| 188 | + |
|
| 189 | + // Failure page content. |
|
| 190 | + 'failure_page' => array( |
|
| 191 | + 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
| 192 | + 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
| 193 | + 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 194 | + 'parent' => 'gp-checkout', |
|
| 195 | + ), |
|
| 196 | + |
|
| 197 | + // Subscriptions history page. |
|
| 198 | + 'invoice_subscription_page' => array( |
|
| 199 | + 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
| 200 | + 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
| 201 | + 'content' => ' |
|
| 202 | 202 | <!-- wp:shortcode --> |
| 203 | 203 | [wpinv_subscriptions] |
| 204 | 204 | <!-- /wp:shortcode --> |
| 205 | 205 | ', |
| 206 | - 'parent' => '', |
|
| 207 | - ), |
|
| 206 | + 'parent' => '', |
|
| 207 | + ), |
|
| 208 | 208 | |
| 209 | - ) |
|
| 210 | - ); |
|
| 209 | + ) |
|
| 210 | + ); |
|
| 211 | 211 | |
| 212 | - } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Re-create GetPaid pages. |
|
| 216 | - * |
|
| 217 | - */ |
|
| 218 | - public function create_pages() { |
|
| 214 | + /** |
|
| 215 | + * Re-create GetPaid pages. |
|
| 216 | + * |
|
| 217 | + */ |
|
| 218 | + public function create_pages() { |
|
| 219 | 219 | |
| 220 | - foreach ( self::get_pages() as $key => $page ) { |
|
| 221 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
| 222 | - } |
|
| 220 | + foreach ( self::get_pages() as $key => $page ) { |
|
| 221 | + wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Create subscriptions table. |
|
| 228 | - * |
|
| 229 | - */ |
|
| 230 | - public function create_subscriptions_table() { |
|
| 226 | + /** |
|
| 227 | + * Create subscriptions table. |
|
| 228 | + * |
|
| 229 | + */ |
|
| 230 | + public function create_subscriptions_table() { |
|
| 231 | 231 | |
| 232 | - global $wpdb; |
|
| 232 | + global $wpdb; |
|
| 233 | 233 | |
| 234 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 234 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 235 | 235 | |
| 236 | - // Create tables. |
|
| 237 | - $charset_collate = $wpdb->get_charset_collate(); |
|
| 238 | - $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions ( |
|
| 236 | + // Create tables. |
|
| 237 | + $charset_collate = $wpdb->get_charset_collate(); |
|
| 238 | + $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions ( |
|
| 239 | 239 | id bigint(20) unsigned NOT NULL auto_increment, |
| 240 | 240 | customer_id bigint(20) NOT NULL, |
| 241 | 241 | frequency int(11) NOT NULL DEFAULT '1', |
@@ -258,22 +258,22 @@ discard block |
||
| 258 | 258 | KEY customer_and_status (customer_id, status) |
| 259 | 259 | ) $charset_collate;"; |
| 260 | 260 | |
| 261 | - dbDelta( $sql ); |
|
| 261 | + dbDelta( $sql ); |
|
| 262 | 262 | |
| 263 | - } |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - /** |
|
| 266 | - * Create invoices table. |
|
| 267 | - * |
|
| 268 | - */ |
|
| 269 | - public function create_invoices_table() { |
|
| 270 | - global $wpdb; |
|
| 265 | + /** |
|
| 266 | + * Create invoices table. |
|
| 267 | + * |
|
| 268 | + */ |
|
| 269 | + public function create_invoices_table() { |
|
| 270 | + global $wpdb; |
|
| 271 | 271 | |
| 272 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 272 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 273 | 273 | |
| 274 | - // Create tables. |
|
| 275 | - $charset_collate = $wpdb->get_charset_collate(); |
|
| 276 | - $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices ( |
|
| 274 | + // Create tables. |
|
| 275 | + $charset_collate = $wpdb->get_charset_collate(); |
|
| 276 | + $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices ( |
|
| 277 | 277 | post_id BIGINT(20) NOT NULL, |
| 278 | 278 | `number` VARCHAR(100), |
| 279 | 279 | `key` VARCHAR(100), |
@@ -309,22 +309,22 @@ discard block |
||
| 309 | 309 | KEY `key` (`key`) |
| 310 | 310 | ) $charset_collate;"; |
| 311 | 311 | |
| 312 | - dbDelta( $sql ); |
|
| 312 | + dbDelta( $sql ); |
|
| 313 | 313 | |
| 314 | - } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - /** |
|
| 317 | - * Create invoice items table. |
|
| 318 | - * |
|
| 319 | - */ |
|
| 320 | - public function create_invoice_items_table() { |
|
| 321 | - global $wpdb; |
|
| 316 | + /** |
|
| 317 | + * Create invoice items table. |
|
| 318 | + * |
|
| 319 | + */ |
|
| 320 | + public function create_invoice_items_table() { |
|
| 321 | + global $wpdb; |
|
| 322 | 322 | |
| 323 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 323 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 324 | 324 | |
| 325 | - // Create tables. |
|
| 326 | - $charset_collate = $wpdb->get_charset_collate(); |
|
| 327 | - $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items ( |
|
| 325 | + // Create tables. |
|
| 326 | + $charset_collate = $wpdb->get_charset_collate(); |
|
| 327 | + $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items ( |
|
| 328 | 328 | ID BIGINT(20) NOT NULL AUTO_INCREMENT, |
| 329 | 329 | post_id BIGINT(20) NOT NULL, |
| 330 | 330 | item_id BIGINT(20) NOT NULL, |
@@ -346,159 +346,159 @@ discard block |
||
| 346 | 346 | KEY post_id (post_id) |
| 347 | 347 | ) $charset_collate;"; |
| 348 | 348 | |
| 349 | - dbDelta( $sql ); |
|
| 350 | - |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Migrates old invoices to new invoices. |
|
| 355 | - * |
|
| 356 | - */ |
|
| 357 | - public function migrate_old_invoices() { |
|
| 358 | - global $wpdb; |
|
| 359 | - |
|
| 360 | - $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 361 | - $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
| 362 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
| 363 | - $invoices = array_unique( |
|
| 364 | - get_posts( |
|
| 365 | - array( |
|
| 366 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
| 367 | - 'posts_per_page' => -1, |
|
| 368 | - 'fields' => 'ids', |
|
| 369 | - 'post_status' => array_keys( get_post_stati() ), |
|
| 370 | - 'exclude' => (array) $migrated, |
|
| 371 | - ) |
|
| 372 | - ) |
|
| 373 | - ); |
|
| 374 | - |
|
| 375 | - // Abort if we do not have any invoices. |
|
| 376 | - if ( empty( $invoices ) ) { |
|
| 377 | - return; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
| 381 | - |
|
| 382 | - $invoice_rows = array(); |
|
| 383 | - foreach ( $invoices as $invoice ) { |
|
| 384 | - |
|
| 385 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
| 386 | - |
|
| 387 | - if ( empty( $invoice->ID ) ) { |
|
| 388 | - return; |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - $fields = array ( |
|
| 392 | - 'post_id' => $invoice->ID, |
|
| 393 | - 'number' => $invoice->get_number(), |
|
| 394 | - 'key' => $invoice->get_key(), |
|
| 395 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
| 396 | - 'mode' => $invoice->mode, |
|
| 397 | - 'user_ip' => $invoice->get_ip(), |
|
| 398 | - 'first_name' => $invoice->get_first_name(), |
|
| 399 | - 'last_name' => $invoice->get_last_name(), |
|
| 400 | - 'address' => $invoice->get_address(), |
|
| 401 | - 'city' => $invoice->city, |
|
| 402 | - 'state' => $invoice->state, |
|
| 403 | - 'country' => $invoice->country, |
|
| 404 | - 'zip' => $invoice->zip, |
|
| 405 | - 'adddress_confirmed' => (int) $invoice->adddress_confirmed, |
|
| 406 | - 'gateway' => $invoice->get_gateway(), |
|
| 407 | - 'transaction_id' => $invoice->get_transaction_id(), |
|
| 408 | - 'currency' => $invoice->get_currency(), |
|
| 409 | - 'subtotal' => $invoice->get_subtotal(), |
|
| 410 | - 'tax' => $invoice->get_tax(), |
|
| 411 | - 'fees_total' => $invoice->get_fees_total(), |
|
| 412 | - 'total' => $invoice->get_total(), |
|
| 413 | - 'discount' => $invoice->get_discount(), |
|
| 414 | - 'discount_code' => $invoice->get_discount_code(), |
|
| 415 | - 'disable_taxes' => $invoice->disable_taxes, |
|
| 416 | - 'due_date' => $invoice->get_due_date(), |
|
| 417 | - 'completed_date' => $invoice->get_completed_date(), |
|
| 418 | - 'company' => $invoice->company, |
|
| 419 | - 'vat_number' => $invoice->vat_number, |
|
| 420 | - 'vat_rate' => $invoice->vat_rate, |
|
| 421 | - 'custom_meta' => $invoice->payment_meta |
|
| 422 | - ); |
|
| 423 | - |
|
| 424 | - foreach ( $fields as $key => $val ) { |
|
| 425 | - if ( is_null( $val ) ) { |
|
| 426 | - $val = ''; |
|
| 427 | - } |
|
| 428 | - $val = maybe_serialize( $val ); |
|
| 429 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - $fields = implode( ', ', $fields ); |
|
| 433 | - $invoice_rows[] = "($fields)"; |
|
| 434 | - |
|
| 435 | - $item_rows = array(); |
|
| 436 | - $item_columns = array(); |
|
| 437 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
| 438 | - $fields = array( |
|
| 439 | - 'post_id' => $invoice->ID, |
|
| 440 | - 'item_id' => $details['id'], |
|
| 441 | - 'item_name' => $details['name'], |
|
| 442 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
| 443 | - 'vat_rate' => $details['vat_rate'], |
|
| 444 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
| 445 | - 'tax' => $details['tax'], |
|
| 446 | - 'item_price' => $details['item_price'], |
|
| 447 | - 'custom_price' => $details['custom_price'], |
|
| 448 | - 'quantity' => $details['quantity'], |
|
| 449 | - 'discount' => $details['discount'], |
|
| 450 | - 'subtotal' => $details['subtotal'], |
|
| 451 | - 'price' => $details['price'], |
|
| 452 | - 'meta' => $details['meta'], |
|
| 453 | - 'fees' => $details['fees'], |
|
| 454 | - ); |
|
| 455 | - |
|
| 456 | - $item_columns = array_keys ( $fields ); |
|
| 457 | - |
|
| 458 | - foreach ( $fields as $key => $val ) { |
|
| 459 | - if ( is_null( $val ) ) { |
|
| 460 | - $val = ''; |
|
| 461 | - } |
|
| 462 | - $val = maybe_serialize( $val ); |
|
| 463 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - $fields = implode( ', ', $fields ); |
|
| 467 | - $item_rows[] = "($fields)"; |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - $item_rows = implode( ', ', $item_rows ); |
|
| 471 | - $item_columns = implode( ', ', $item_columns ); |
|
| 472 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - if ( empty( $invoice_rows ) ) { |
|
| 476 | - return; |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
| 480 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
| 481 | - |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * Migrates old invoices to new invoices. |
|
| 486 | - * |
|
| 487 | - */ |
|
| 488 | - public static function rename_gateways_label() { |
|
| 489 | - global $wpdb; |
|
| 490 | - |
|
| 491 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
| 492 | - |
|
| 493 | - $wpdb->update( |
|
| 494 | - $wpdb->prefix . 'getpaid_invoices', |
|
| 495 | - array( 'gateway' => $gateway ), |
|
| 496 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
| 497 | - '%s', |
|
| 498 | - '%s' |
|
| 499 | - ); |
|
| 500 | - |
|
| 501 | - } |
|
| 502 | - } |
|
| 349 | + dbDelta( $sql ); |
|
| 350 | + |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Migrates old invoices to new invoices. |
|
| 355 | + * |
|
| 356 | + */ |
|
| 357 | + public function migrate_old_invoices() { |
|
| 358 | + global $wpdb; |
|
| 359 | + |
|
| 360 | + $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 361 | + $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
| 362 | + $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
| 363 | + $invoices = array_unique( |
|
| 364 | + get_posts( |
|
| 365 | + array( |
|
| 366 | + 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
| 367 | + 'posts_per_page' => -1, |
|
| 368 | + 'fields' => 'ids', |
|
| 369 | + 'post_status' => array_keys( get_post_stati() ), |
|
| 370 | + 'exclude' => (array) $migrated, |
|
| 371 | + ) |
|
| 372 | + ) |
|
| 373 | + ); |
|
| 374 | + |
|
| 375 | + // Abort if we do not have any invoices. |
|
| 376 | + if ( empty( $invoices ) ) { |
|
| 377 | + return; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
| 381 | + |
|
| 382 | + $invoice_rows = array(); |
|
| 383 | + foreach ( $invoices as $invoice ) { |
|
| 384 | + |
|
| 385 | + $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
| 386 | + |
|
| 387 | + if ( empty( $invoice->ID ) ) { |
|
| 388 | + return; |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + $fields = array ( |
|
| 392 | + 'post_id' => $invoice->ID, |
|
| 393 | + 'number' => $invoice->get_number(), |
|
| 394 | + 'key' => $invoice->get_key(), |
|
| 395 | + 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
| 396 | + 'mode' => $invoice->mode, |
|
| 397 | + 'user_ip' => $invoice->get_ip(), |
|
| 398 | + 'first_name' => $invoice->get_first_name(), |
|
| 399 | + 'last_name' => $invoice->get_last_name(), |
|
| 400 | + 'address' => $invoice->get_address(), |
|
| 401 | + 'city' => $invoice->city, |
|
| 402 | + 'state' => $invoice->state, |
|
| 403 | + 'country' => $invoice->country, |
|
| 404 | + 'zip' => $invoice->zip, |
|
| 405 | + 'adddress_confirmed' => (int) $invoice->adddress_confirmed, |
|
| 406 | + 'gateway' => $invoice->get_gateway(), |
|
| 407 | + 'transaction_id' => $invoice->get_transaction_id(), |
|
| 408 | + 'currency' => $invoice->get_currency(), |
|
| 409 | + 'subtotal' => $invoice->get_subtotal(), |
|
| 410 | + 'tax' => $invoice->get_tax(), |
|
| 411 | + 'fees_total' => $invoice->get_fees_total(), |
|
| 412 | + 'total' => $invoice->get_total(), |
|
| 413 | + 'discount' => $invoice->get_discount(), |
|
| 414 | + 'discount_code' => $invoice->get_discount_code(), |
|
| 415 | + 'disable_taxes' => $invoice->disable_taxes, |
|
| 416 | + 'due_date' => $invoice->get_due_date(), |
|
| 417 | + 'completed_date' => $invoice->get_completed_date(), |
|
| 418 | + 'company' => $invoice->company, |
|
| 419 | + 'vat_number' => $invoice->vat_number, |
|
| 420 | + 'vat_rate' => $invoice->vat_rate, |
|
| 421 | + 'custom_meta' => $invoice->payment_meta |
|
| 422 | + ); |
|
| 423 | + |
|
| 424 | + foreach ( $fields as $key => $val ) { |
|
| 425 | + if ( is_null( $val ) ) { |
|
| 426 | + $val = ''; |
|
| 427 | + } |
|
| 428 | + $val = maybe_serialize( $val ); |
|
| 429 | + $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + $fields = implode( ', ', $fields ); |
|
| 433 | + $invoice_rows[] = "($fields)"; |
|
| 434 | + |
|
| 435 | + $item_rows = array(); |
|
| 436 | + $item_columns = array(); |
|
| 437 | + foreach ( $invoice->get_cart_details() as $details ) { |
|
| 438 | + $fields = array( |
|
| 439 | + 'post_id' => $invoice->ID, |
|
| 440 | + 'item_id' => $details['id'], |
|
| 441 | + 'item_name' => $details['name'], |
|
| 442 | + 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
| 443 | + 'vat_rate' => $details['vat_rate'], |
|
| 444 | + 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
| 445 | + 'tax' => $details['tax'], |
|
| 446 | + 'item_price' => $details['item_price'], |
|
| 447 | + 'custom_price' => $details['custom_price'], |
|
| 448 | + 'quantity' => $details['quantity'], |
|
| 449 | + 'discount' => $details['discount'], |
|
| 450 | + 'subtotal' => $details['subtotal'], |
|
| 451 | + 'price' => $details['price'], |
|
| 452 | + 'meta' => $details['meta'], |
|
| 453 | + 'fees' => $details['fees'], |
|
| 454 | + ); |
|
| 455 | + |
|
| 456 | + $item_columns = array_keys ( $fields ); |
|
| 457 | + |
|
| 458 | + foreach ( $fields as $key => $val ) { |
|
| 459 | + if ( is_null( $val ) ) { |
|
| 460 | + $val = ''; |
|
| 461 | + } |
|
| 462 | + $val = maybe_serialize( $val ); |
|
| 463 | + $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + $fields = implode( ', ', $fields ); |
|
| 467 | + $item_rows[] = "($fields)"; |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + $item_rows = implode( ', ', $item_rows ); |
|
| 471 | + $item_columns = implode( ', ', $item_columns ); |
|
| 472 | + $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + if ( empty( $invoice_rows ) ) { |
|
| 476 | + return; |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + $invoice_rows = implode( ', ', $invoice_rows ); |
|
| 480 | + $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
| 481 | + |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * Migrates old invoices to new invoices. |
|
| 486 | + * |
|
| 487 | + */ |
|
| 488 | + public static function rename_gateways_label() { |
|
| 489 | + global $wpdb; |
|
| 490 | + |
|
| 491 | + foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
| 492 | + |
|
| 493 | + $wpdb->update( |
|
| 494 | + $wpdb->prefix . 'getpaid_invoices', |
|
| 495 | + array( 'gateway' => $gateway ), |
|
| 496 | + array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
| 497 | + '%s', |
|
| 498 | + '%s' |
|
| 499 | + ); |
|
| 500 | + |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | 503 | |
| 504 | 504 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @since 2.0.2 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * The main installer/updater class. |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @param string $upgrade_from The current invoicing version. |
| 27 | 27 | */ |
| 28 | - public function upgrade_db( $upgrade_from ) { |
|
| 28 | + public function upgrade_db($upgrade_from) { |
|
| 29 | 29 | |
| 30 | 30 | // Save the current invoicing version. |
| 31 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
| 31 | + update_option('wpinv_version', WPINV_VERSION); |
|
| 32 | 32 | |
| 33 | 33 | // Setup the invoice Custom Post Type. |
| 34 | 34 | GetPaid_Post_Types::register_post_types(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | // Create any missing database tables. |
| 49 | 49 | $method = "upgrade_from_$upgrade_from"; |
| 50 | 50 | |
| 51 | - if ( method_exists( $this, $method ) ) { |
|
| 51 | + if (method_exists($this, $method)) { |
|
| 52 | 52 | $this->$method(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->create_invoice_items_table(); |
| 65 | 65 | |
| 66 | 66 | // Save default tax rates. |
| 67 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 67 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -75,28 +75,28 @@ discard block |
||
| 75 | 75 | global $wpdb; |
| 76 | 76 | |
| 77 | 77 | // Invoices. |
| 78 | - $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
| 79 | - if ( ! empty( $results ) ) { |
|
| 80 | - $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
| 78 | + $results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
| 79 | + if (!empty($results)) { |
|
| 80 | + $wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
| 81 | 81 | |
| 82 | 82 | // Clean post cache |
| 83 | - foreach ( $results as $row ) { |
|
| 84 | - clean_post_cache( $row->ID ); |
|
| 83 | + foreach ($results as $row) { |
|
| 84 | + clean_post_cache($row->ID); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Item meta key changes |
| 90 | 90 | $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
| 91 | - $results = $wpdb->get_results( $query ); |
|
| 91 | + $results = $wpdb->get_results($query); |
|
| 92 | 92 | |
| 93 | - if ( ! empty( $results ) ) { |
|
| 94 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
| 95 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
| 96 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
| 93 | + if (!empty($results)) { |
|
| 94 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
| 95 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
| 96 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
| 97 | 97 | |
| 98 | - foreach ( $results as $row ) { |
|
| 99 | - clean_post_cache( $row->post_id ); |
|
| 98 | + foreach ($results as $row) { |
|
| 99 | + clean_post_cache($row->post_id); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function upgrade_from_207() { |
| 131 | 131 | global $wpdb; |
| 132 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
| 132 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);"); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | */ |
| 139 | 139 | public function add_capabilities() { |
| 140 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
| 140 | + $GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | // Checkout page. |
| 154 | 154 | 'checkout_page' => array( |
| 155 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
| 156 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
| 155 | + 'name' => _x('gp-checkout', 'Page slug', 'invoicing'), |
|
| 156 | + 'title' => _x('Checkout', 'Page title', 'invoicing'), |
|
| 157 | 157 | 'content' => ' |
| 158 | 158 | <!-- wp:shortcode --> |
| 159 | 159 | [wpinv_checkout] |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | // Invoice history page. |
| 166 | 166 | 'invoice_history_page' => array( |
| 167 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
| 168 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
| 167 | + 'name' => _x('gp-invoices', 'Page slug', 'invoicing'), |
|
| 168 | + 'title' => _x('My Invoices', 'Page title', 'invoicing'), |
|
| 169 | 169 | 'content' => ' |
| 170 | 170 | <!-- wp:shortcode --> |
| 171 | 171 | [wpinv_history] |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | // Success page content. |
| 178 | 178 | 'success_page' => array( |
| 179 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
| 180 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
| 179 | + 'name' => _x('gp-receipt', 'Page slug', 'invoicing'), |
|
| 180 | + 'title' => _x('Payment Confirmation', 'Page title', 'invoicing'), |
|
| 181 | 181 | 'content' => ' |
| 182 | 182 | <!-- wp:shortcode --> |
| 183 | 183 | [wpinv_receipt] |
@@ -188,16 +188,16 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | // Failure page content. |
| 190 | 190 | 'failure_page' => array( |
| 191 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
| 192 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
| 193 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 191 | + 'name' => _x('gp-transaction-failed', 'Page slug', 'invoicing'), |
|
| 192 | + 'title' => _x('Transaction Failed', 'Page title', 'invoicing'), |
|
| 193 | + 'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
| 194 | 194 | 'parent' => 'gp-checkout', |
| 195 | 195 | ), |
| 196 | 196 | |
| 197 | 197 | // Subscriptions history page. |
| 198 | 198 | 'invoice_subscription_page' => array( |
| 199 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
| 200 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
| 199 | + 'name' => _x('gp-subscriptions', 'Page slug', 'invoicing'), |
|
| 200 | + 'title' => _x('My Subscriptions', 'Page title', 'invoicing'), |
|
| 201 | 201 | 'content' => ' |
| 202 | 202 | <!-- wp:shortcode --> |
| 203 | 203 | [wpinv_subscriptions] |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function create_pages() { |
| 219 | 219 | |
| 220 | - foreach ( self::get_pages() as $key => $page ) { |
|
| 221 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
| 220 | + foreach (self::get_pages() as $key => $page) { |
|
| 221 | + wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | global $wpdb; |
| 233 | 233 | |
| 234 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 234 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 235 | 235 | |
| 236 | 236 | // Create tables. |
| 237 | 237 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | KEY customer_and_status (customer_id, status) |
| 259 | 259 | ) $charset_collate;"; |
| 260 | 260 | |
| 261 | - dbDelta( $sql ); |
|
| 261 | + dbDelta($sql); |
|
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | public function create_invoices_table() { |
| 270 | 270 | global $wpdb; |
| 271 | 271 | |
| 272 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 272 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 273 | 273 | |
| 274 | 274 | // Create tables. |
| 275 | 275 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | KEY `key` (`key`) |
| 310 | 310 | ) $charset_collate;"; |
| 311 | 311 | |
| 312 | - dbDelta( $sql ); |
|
| 312 | + dbDelta($sql); |
|
| 313 | 313 | |
| 314 | 314 | } |
| 315 | 315 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | public function create_invoice_items_table() { |
| 321 | 321 | global $wpdb; |
| 322 | 322 | |
| 323 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 323 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 324 | 324 | |
| 325 | 325 | // Create tables. |
| 326 | 326 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | KEY post_id (post_id) |
| 347 | 347 | ) $charset_collate;"; |
| 348 | 348 | |
| 349 | - dbDelta( $sql ); |
|
| 349 | + dbDelta($sql); |
|
| 350 | 350 | |
| 351 | 351 | } |
| 352 | 352 | |
@@ -359,40 +359,40 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
| 361 | 361 | $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
| 362 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
| 362 | + $migrated = $wpdb->get_col("SELECT post_id FROM $invoices_table"); |
|
| 363 | 363 | $invoices = array_unique( |
| 364 | 364 | get_posts( |
| 365 | 365 | array( |
| 366 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
| 366 | + 'post_type' => array('wpi_invoice', 'wpi_quote'), |
|
| 367 | 367 | 'posts_per_page' => -1, |
| 368 | 368 | 'fields' => 'ids', |
| 369 | - 'post_status' => array_keys( get_post_stati() ), |
|
| 369 | + 'post_status' => array_keys(get_post_stati()), |
|
| 370 | 370 | 'exclude' => (array) $migrated, |
| 371 | 371 | ) |
| 372 | 372 | ) |
| 373 | 373 | ); |
| 374 | 374 | |
| 375 | 375 | // Abort if we do not have any invoices. |
| 376 | - if ( empty( $invoices ) ) { |
|
| 376 | + if (empty($invoices)) { |
|
| 377 | 377 | return; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
| 380 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php'); |
|
| 381 | 381 | |
| 382 | 382 | $invoice_rows = array(); |
| 383 | - foreach ( $invoices as $invoice ) { |
|
| 383 | + foreach ($invoices as $invoice) { |
|
| 384 | 384 | |
| 385 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
| 385 | + $invoice = new WPInv_Legacy_Invoice($invoice); |
|
| 386 | 386 | |
| 387 | - if ( empty( $invoice->ID ) ) { |
|
| 387 | + if (empty($invoice->ID)) { |
|
| 388 | 388 | return; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - $fields = array ( |
|
| 391 | + $fields = array( |
|
| 392 | 392 | 'post_id' => $invoice->ID, |
| 393 | 393 | 'number' => $invoice->get_number(), |
| 394 | 394 | 'key' => $invoice->get_key(), |
| 395 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
| 395 | + 'type' => str_replace('wpi_', '', $invoice->post_type), |
|
| 396 | 396 | 'mode' => $invoice->mode, |
| 397 | 397 | 'user_ip' => $invoice->get_ip(), |
| 398 | 398 | 'first_name' => $invoice->get_first_name(), |
@@ -421,27 +421,27 @@ discard block |
||
| 421 | 421 | 'custom_meta' => $invoice->payment_meta |
| 422 | 422 | ); |
| 423 | 423 | |
| 424 | - foreach ( $fields as $key => $val ) { |
|
| 425 | - if ( is_null( $val ) ) { |
|
| 424 | + foreach ($fields as $key => $val) { |
|
| 425 | + if (is_null($val)) { |
|
| 426 | 426 | $val = ''; |
| 427 | 427 | } |
| 428 | - $val = maybe_serialize( $val ); |
|
| 429 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 428 | + $val = maybe_serialize($val); |
|
| 429 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - $fields = implode( ', ', $fields ); |
|
| 432 | + $fields = implode(', ', $fields); |
|
| 433 | 433 | $invoice_rows[] = "($fields)"; |
| 434 | 434 | |
| 435 | 435 | $item_rows = array(); |
| 436 | 436 | $item_columns = array(); |
| 437 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
| 437 | + foreach ($invoice->get_cart_details() as $details) { |
|
| 438 | 438 | $fields = array( |
| 439 | 439 | 'post_id' => $invoice->ID, |
| 440 | 440 | 'item_id' => $details['id'], |
| 441 | 441 | 'item_name' => $details['name'], |
| 442 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
| 442 | + 'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'], |
|
| 443 | 443 | 'vat_rate' => $details['vat_rate'], |
| 444 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
| 444 | + 'vat_class' => empty($details['vat_class']) ? '_standard' : $details['vat_class'], |
|
| 445 | 445 | 'tax' => $details['tax'], |
| 446 | 446 | 'item_price' => $details['item_price'], |
| 447 | 447 | 'custom_price' => $details['custom_price'], |
@@ -453,31 +453,31 @@ discard block |
||
| 453 | 453 | 'fees' => $details['fees'], |
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | - $item_columns = array_keys ( $fields ); |
|
| 456 | + $item_columns = array_keys($fields); |
|
| 457 | 457 | |
| 458 | - foreach ( $fields as $key => $val ) { |
|
| 459 | - if ( is_null( $val ) ) { |
|
| 458 | + foreach ($fields as $key => $val) { |
|
| 459 | + if (is_null($val)) { |
|
| 460 | 460 | $val = ''; |
| 461 | 461 | } |
| 462 | - $val = maybe_serialize( $val ); |
|
| 463 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 462 | + $val = maybe_serialize($val); |
|
| 463 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - $fields = implode( ', ', $fields ); |
|
| 466 | + $fields = implode(', ', $fields); |
|
| 467 | 467 | $item_rows[] = "($fields)"; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - $item_rows = implode( ', ', $item_rows ); |
|
| 471 | - $item_columns = implode( ', ', $item_columns ); |
|
| 472 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
| 470 | + $item_rows = implode(', ', $item_rows); |
|
| 471 | + $item_columns = implode(', ', $item_columns); |
|
| 472 | + $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows"); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if ( empty( $invoice_rows ) ) { |
|
| 475 | + if (empty($invoice_rows)) { |
|
| 476 | 476 | return; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
| 480 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
| 479 | + $invoice_rows = implode(', ', $invoice_rows); |
|
| 480 | + $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows"); |
|
| 481 | 481 | |
| 482 | 482 | } |
| 483 | 483 | |
@@ -488,12 +488,12 @@ discard block |
||
| 488 | 488 | public static function rename_gateways_label() { |
| 489 | 489 | global $wpdb; |
| 490 | 490 | |
| 491 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
| 491 | + foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) { |
|
| 492 | 492 | |
| 493 | 493 | $wpdb->update( |
| 494 | 494 | $wpdb->prefix . 'getpaid_invoices', |
| 495 | - array( 'gateway' => $gateway ), |
|
| 496 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
| 495 | + array('gateway' => $gateway), |
|
| 496 | + array('gateway' => wpinv_get_gateway_admin_label($gateway)), |
|
| 497 | 497 | '%s', |
| 498 | 498 | '%s' |
| 499 | 499 | ); |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; |
|
| 10 | + exit; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | 16 | add_action('after_setup_theme', function () { |
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | - $this_version = "0.1.49"; |
|
| 19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | - } |
|
| 17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | + $this_version = "0.1.49"; |
|
| 19 | + if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | + $ayecode_ui_version = $this_version ; |
|
| 21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | + } |
|
| 23 | 23 | },0); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
| 27 | 27 | */ |
| 28 | 28 | add_action('after_setup_theme', function () { |
| 29 | - global $ayecode_ui_file_key; |
|
| 30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 33 | - } |
|
| 29 | + global $ayecode_ui_file_key; |
|
| 30 | + if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | + include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | + include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 33 | + } |
|
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | 39 | if(!function_exists('aui')){ |
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 44 | - return AUI::instance(); |
|
| 45 | - } |
|
| 40 | + function aui(){ |
|
| 41 | + if(!class_exists("AUI",false)){ |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | + return AUI::instance(); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -6,39 +6,39 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | -add_action('after_setup_theme', function () { |
|
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 16 | +add_action('after_setup_theme', function() { |
|
| 17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
| 18 | 18 | $this_version = "0.1.49"; |
| 19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 19 | + if (version_compare($this_version, $ayecode_ui_version, '>')) { |
|
| 20 | + $ayecode_ui_version = $this_version; |
|
| 21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
| 22 | 22 | } |
| 23 | 23 | },0); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
| 27 | 27 | */ |
| 28 | -add_action('after_setup_theme', function () { |
|
| 28 | +add_action('after_setup_theme', function() { |
|
| 29 | 29 | global $ayecode_ui_file_key; |
| 30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
| 31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
| 32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
| 33 | 33 | } |
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | -if(!function_exists('aui')){ |
|
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 39 | +if (!function_exists('aui')) { |
|
| 40 | + function aui() { |
|
| 41 | + if (!class_exists("AUI", false)) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | return AUI::instance(); |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | class InstalledVersions |
| 13 | 13 | { |
| 14 | 14 | private static $installed = array ( |
| 15 | - 'root' => |
|
| 16 | - array ( |
|
| 15 | + 'root' => |
|
| 16 | + array ( |
|
| 17 | 17 | 'pretty_version' => 'dev-master', |
| 18 | 18 | 'version' => 'dev-master', |
| 19 | 19 | 'aliases' => |
@@ -21,87 +21,87 @@ discard block |
||
| 21 | 21 | ), |
| 22 | 22 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
| 23 | 23 | 'name' => 'ayecode/invoicing', |
| 24 | - ), |
|
| 25 | - 'versions' => |
|
| 26 | - array ( |
|
| 24 | + ), |
|
| 25 | + 'versions' => |
|
| 26 | + array ( |
|
| 27 | 27 | 'ayecode/ayecode-connect-helper' => |
| 28 | 28 | array ( |
| 29 | - 'pretty_version' => '1.0.3', |
|
| 30 | - 'version' => '1.0.3.0', |
|
| 31 | - 'aliases' => |
|
| 32 | - array ( |
|
| 33 | - ), |
|
| 34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 29 | + 'pretty_version' => '1.0.3', |
|
| 30 | + 'version' => '1.0.3.0', |
|
| 31 | + 'aliases' => |
|
| 32 | + array ( |
|
| 33 | + ), |
|
| 34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 35 | 35 | ), |
| 36 | 36 | 'ayecode/invoicing' => |
| 37 | 37 | array ( |
| 38 | - 'pretty_version' => 'dev-master', |
|
| 39 | - 'version' => 'dev-master', |
|
| 40 | - 'aliases' => |
|
| 41 | - array ( |
|
| 42 | - ), |
|
| 43 | - 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
| 38 | + 'pretty_version' => 'dev-master', |
|
| 39 | + 'version' => 'dev-master', |
|
| 40 | + 'aliases' => |
|
| 41 | + array ( |
|
| 42 | + ), |
|
| 43 | + 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
| 44 | 44 | ), |
| 45 | 45 | 'ayecode/wp-ayecode-ui' => |
| 46 | 46 | array ( |
| 47 | - 'pretty_version' => '0.1.49', |
|
| 48 | - 'version' => '0.1.49.0', |
|
| 49 | - 'aliases' => |
|
| 50 | - array ( |
|
| 51 | - ), |
|
| 52 | - 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
| 47 | + 'pretty_version' => '0.1.49', |
|
| 48 | + 'version' => '0.1.49.0', |
|
| 49 | + 'aliases' => |
|
| 50 | + array ( |
|
| 51 | + ), |
|
| 52 | + 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
| 53 | 53 | ), |
| 54 | 54 | 'ayecode/wp-font-awesome-settings' => |
| 55 | 55 | array ( |
| 56 | - 'pretty_version' => '1.0.12', |
|
| 57 | - 'version' => '1.0.12.0', |
|
| 58 | - 'aliases' => |
|
| 59 | - array ( |
|
| 60 | - ), |
|
| 61 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 56 | + 'pretty_version' => '1.0.12', |
|
| 57 | + 'version' => '1.0.12.0', |
|
| 58 | + 'aliases' => |
|
| 59 | + array ( |
|
| 60 | + ), |
|
| 61 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 62 | 62 | ), |
| 63 | 63 | 'ayecode/wp-super-duper' => |
| 64 | 64 | array ( |
| 65 | - 'pretty_version' => '1.0.26', |
|
| 66 | - 'version' => '1.0.26.0', |
|
| 67 | - 'aliases' => |
|
| 68 | - array ( |
|
| 69 | - ), |
|
| 70 | - 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
| 65 | + 'pretty_version' => '1.0.26', |
|
| 66 | + 'version' => '1.0.26.0', |
|
| 67 | + 'aliases' => |
|
| 68 | + array ( |
|
| 69 | + ), |
|
| 70 | + 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
| 71 | 71 | ), |
| 72 | 72 | 'composer/installers' => |
| 73 | 73 | array ( |
| 74 | - 'pretty_version' => 'v1.11.0', |
|
| 75 | - 'version' => '1.11.0.0', |
|
| 76 | - 'aliases' => |
|
| 77 | - array ( |
|
| 78 | - ), |
|
| 79 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
| 74 | + 'pretty_version' => 'v1.11.0', |
|
| 75 | + 'version' => '1.11.0.0', |
|
| 76 | + 'aliases' => |
|
| 77 | + array ( |
|
| 78 | + ), |
|
| 79 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
| 80 | 80 | ), |
| 81 | 81 | 'maxmind-db/reader' => |
| 82 | 82 | array ( |
| 83 | - 'pretty_version' => 'v1.6.0', |
|
| 84 | - 'version' => '1.6.0.0', |
|
| 85 | - 'aliases' => |
|
| 86 | - array ( |
|
| 87 | - ), |
|
| 88 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
| 83 | + 'pretty_version' => 'v1.6.0', |
|
| 84 | + 'version' => '1.6.0.0', |
|
| 85 | + 'aliases' => |
|
| 86 | + array ( |
|
| 87 | + ), |
|
| 88 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
| 89 | 89 | ), |
| 90 | 90 | 'roundcube/plugin-installer' => |
| 91 | 91 | array ( |
| 92 | - 'replaced' => |
|
| 93 | - array ( |
|
| 92 | + 'replaced' => |
|
| 93 | + array ( |
|
| 94 | 94 | 0 => '*', |
| 95 | - ), |
|
| 95 | + ), |
|
| 96 | 96 | ), |
| 97 | 97 | 'shama/baton' => |
| 98 | 98 | array ( |
| 99 | - 'replaced' => |
|
| 100 | - array ( |
|
| 99 | + 'replaced' => |
|
| 100 | + array ( |
|
| 101 | 101 | 0 => '*', |
| 102 | - ), |
|
| 102 | + ), |
|
| 103 | + ), |
|
| 103 | 104 | ), |
| 104 | - ), |
|
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | |
@@ -11,93 +11,93 @@ |
||
| 11 | 11 | |
| 12 | 12 | class InstalledVersions |
| 13 | 13 | { |
| 14 | -private static $installed = array ( |
|
| 14 | +private static $installed = array( |
|
| 15 | 15 | 'root' => |
| 16 | - array ( |
|
| 16 | + array( |
|
| 17 | 17 | 'pretty_version' => 'dev-master', |
| 18 | 18 | 'version' => 'dev-master', |
| 19 | 19 | 'aliases' => |
| 20 | - array ( |
|
| 20 | + array( |
|
| 21 | 21 | ), |
| 22 | 22 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
| 23 | 23 | 'name' => 'ayecode/invoicing', |
| 24 | 24 | ), |
| 25 | 25 | 'versions' => |
| 26 | - array ( |
|
| 26 | + array( |
|
| 27 | 27 | 'ayecode/ayecode-connect-helper' => |
| 28 | - array ( |
|
| 28 | + array( |
|
| 29 | 29 | 'pretty_version' => '1.0.3', |
| 30 | 30 | 'version' => '1.0.3.0', |
| 31 | 31 | 'aliases' => |
| 32 | - array ( |
|
| 32 | + array( |
|
| 33 | 33 | ), |
| 34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
| 35 | 35 | ), |
| 36 | 36 | 'ayecode/invoicing' => |
| 37 | - array ( |
|
| 37 | + array( |
|
| 38 | 38 | 'pretty_version' => 'dev-master', |
| 39 | 39 | 'version' => 'dev-master', |
| 40 | 40 | 'aliases' => |
| 41 | - array ( |
|
| 41 | + array( |
|
| 42 | 42 | ), |
| 43 | 43 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
| 44 | 44 | ), |
| 45 | 45 | 'ayecode/wp-ayecode-ui' => |
| 46 | - array ( |
|
| 46 | + array( |
|
| 47 | 47 | 'pretty_version' => '0.1.49', |
| 48 | 48 | 'version' => '0.1.49.0', |
| 49 | 49 | 'aliases' => |
| 50 | - array ( |
|
| 50 | + array( |
|
| 51 | 51 | ), |
| 52 | 52 | 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
| 53 | 53 | ), |
| 54 | 54 | 'ayecode/wp-font-awesome-settings' => |
| 55 | - array ( |
|
| 55 | + array( |
|
| 56 | 56 | 'pretty_version' => '1.0.12', |
| 57 | 57 | 'version' => '1.0.12.0', |
| 58 | 58 | 'aliases' => |
| 59 | - array ( |
|
| 59 | + array( |
|
| 60 | 60 | ), |
| 61 | 61 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
| 62 | 62 | ), |
| 63 | 63 | 'ayecode/wp-super-duper' => |
| 64 | - array ( |
|
| 64 | + array( |
|
| 65 | 65 | 'pretty_version' => '1.0.26', |
| 66 | 66 | 'version' => '1.0.26.0', |
| 67 | 67 | 'aliases' => |
| 68 | - array ( |
|
| 68 | + array( |
|
| 69 | 69 | ), |
| 70 | 70 | 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
| 71 | 71 | ), |
| 72 | 72 | 'composer/installers' => |
| 73 | - array ( |
|
| 73 | + array( |
|
| 74 | 74 | 'pretty_version' => 'v1.11.0', |
| 75 | 75 | 'version' => '1.11.0.0', |
| 76 | 76 | 'aliases' => |
| 77 | - array ( |
|
| 77 | + array( |
|
| 78 | 78 | ), |
| 79 | 79 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
| 80 | 80 | ), |
| 81 | 81 | 'maxmind-db/reader' => |
| 82 | - array ( |
|
| 82 | + array( |
|
| 83 | 83 | 'pretty_version' => 'v1.6.0', |
| 84 | 84 | 'version' => '1.6.0.0', |
| 85 | 85 | 'aliases' => |
| 86 | - array ( |
|
| 86 | + array( |
|
| 87 | 87 | ), |
| 88 | 88 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
| 89 | 89 | ), |
| 90 | 90 | 'roundcube/plugin-installer' => |
| 91 | - array ( |
|
| 91 | + array( |
|
| 92 | 92 | 'replaced' => |
| 93 | - array ( |
|
| 93 | + array( |
|
| 94 | 94 | 0 => '*', |
| 95 | 95 | ), |
| 96 | 96 | ), |
| 97 | 97 | 'shama/baton' => |
| 98 | - array ( |
|
| 98 | + array( |
|
| 99 | 99 | 'replaced' => |
| 100 | - array ( |
|
| 100 | + array( |
|
| 101 | 101 | 0 => '*', |
| 102 | 102 | ), |
| 103 | 103 | ), |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php return array ( |
| 2 | - 'root' => |
|
| 3 | - array ( |
|
| 2 | + 'root' => |
|
| 3 | + array ( |
|
| 4 | 4 | 'pretty_version' => 'dev-master', |
| 5 | 5 | 'version' => 'dev-master', |
| 6 | 6 | 'aliases' => |
@@ -8,85 +8,85 @@ discard block |
||
| 8 | 8 | ), |
| 9 | 9 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
| 10 | 10 | 'name' => 'ayecode/invoicing', |
| 11 | - ), |
|
| 12 | - 'versions' => |
|
| 13 | - array ( |
|
| 11 | + ), |
|
| 12 | + 'versions' => |
|
| 13 | + array ( |
|
| 14 | 14 | 'ayecode/ayecode-connect-helper' => |
| 15 | 15 | array ( |
| 16 | - 'pretty_version' => '1.0.3', |
|
| 17 | - 'version' => '1.0.3.0', |
|
| 18 | - 'aliases' => |
|
| 19 | - array ( |
|
| 20 | - ), |
|
| 21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 16 | + 'pretty_version' => '1.0.3', |
|
| 17 | + 'version' => '1.0.3.0', |
|
| 18 | + 'aliases' => |
|
| 19 | + array ( |
|
| 20 | + ), |
|
| 21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
| 22 | 22 | ), |
| 23 | 23 | 'ayecode/invoicing' => |
| 24 | 24 | array ( |
| 25 | - 'pretty_version' => 'dev-master', |
|
| 26 | - 'version' => 'dev-master', |
|
| 27 | - 'aliases' => |
|
| 28 | - array ( |
|
| 29 | - ), |
|
| 30 | - 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
| 25 | + 'pretty_version' => 'dev-master', |
|
| 26 | + 'version' => 'dev-master', |
|
| 27 | + 'aliases' => |
|
| 28 | + array ( |
|
| 29 | + ), |
|
| 30 | + 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
| 31 | 31 | ), |
| 32 | 32 | 'ayecode/wp-ayecode-ui' => |
| 33 | 33 | array ( |
| 34 | - 'pretty_version' => '0.1.49', |
|
| 35 | - 'version' => '0.1.49.0', |
|
| 36 | - 'aliases' => |
|
| 37 | - array ( |
|
| 38 | - ), |
|
| 39 | - 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
| 34 | + 'pretty_version' => '0.1.49', |
|
| 35 | + 'version' => '0.1.49.0', |
|
| 36 | + 'aliases' => |
|
| 37 | + array ( |
|
| 38 | + ), |
|
| 39 | + 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
| 40 | 40 | ), |
| 41 | 41 | 'ayecode/wp-font-awesome-settings' => |
| 42 | 42 | array ( |
| 43 | - 'pretty_version' => '1.0.12', |
|
| 44 | - 'version' => '1.0.12.0', |
|
| 45 | - 'aliases' => |
|
| 46 | - array ( |
|
| 47 | - ), |
|
| 48 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 43 | + 'pretty_version' => '1.0.12', |
|
| 44 | + 'version' => '1.0.12.0', |
|
| 45 | + 'aliases' => |
|
| 46 | + array ( |
|
| 47 | + ), |
|
| 48 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
| 49 | 49 | ), |
| 50 | 50 | 'ayecode/wp-super-duper' => |
| 51 | 51 | array ( |
| 52 | - 'pretty_version' => '1.0.26', |
|
| 53 | - 'version' => '1.0.26.0', |
|
| 54 | - 'aliases' => |
|
| 55 | - array ( |
|
| 56 | - ), |
|
| 57 | - 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
| 52 | + 'pretty_version' => '1.0.26', |
|
| 53 | + 'version' => '1.0.26.0', |
|
| 54 | + 'aliases' => |
|
| 55 | + array ( |
|
| 56 | + ), |
|
| 57 | + 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
| 58 | 58 | ), |
| 59 | 59 | 'composer/installers' => |
| 60 | 60 | array ( |
| 61 | - 'pretty_version' => 'v1.11.0', |
|
| 62 | - 'version' => '1.11.0.0', |
|
| 63 | - 'aliases' => |
|
| 64 | - array ( |
|
| 65 | - ), |
|
| 66 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
| 61 | + 'pretty_version' => 'v1.11.0', |
|
| 62 | + 'version' => '1.11.0.0', |
|
| 63 | + 'aliases' => |
|
| 64 | + array ( |
|
| 65 | + ), |
|
| 66 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
| 67 | 67 | ), |
| 68 | 68 | 'maxmind-db/reader' => |
| 69 | 69 | array ( |
| 70 | - 'pretty_version' => 'v1.6.0', |
|
| 71 | - 'version' => '1.6.0.0', |
|
| 72 | - 'aliases' => |
|
| 73 | - array ( |
|
| 74 | - ), |
|
| 75 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
| 70 | + 'pretty_version' => 'v1.6.0', |
|
| 71 | + 'version' => '1.6.0.0', |
|
| 72 | + 'aliases' => |
|
| 73 | + array ( |
|
| 74 | + ), |
|
| 75 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
| 76 | 76 | ), |
| 77 | 77 | 'roundcube/plugin-installer' => |
| 78 | 78 | array ( |
| 79 | - 'replaced' => |
|
| 80 | - array ( |
|
| 79 | + 'replaced' => |
|
| 80 | + array ( |
|
| 81 | 81 | 0 => '*', |
| 82 | - ), |
|
| 82 | + ), |
|
| 83 | 83 | ), |
| 84 | 84 | 'shama/baton' => |
| 85 | 85 | array ( |
| 86 | - 'replaced' => |
|
| 87 | - array ( |
|
| 86 | + 'replaced' => |
|
| 87 | + array ( |
|
| 88 | 88 | 0 => '*', |
| 89 | - ), |
|
| 89 | + ), |
|
| 90 | + ), |
|
| 90 | 91 | ), |
| 91 | - ), |
|
| 92 | 92 | ); |
@@ -1,90 +1,90 @@ |
||
| 1 | -<?php return array ( |
|
| 1 | +<?php return array( |
|
| 2 | 2 | 'root' => |
| 3 | - array ( |
|
| 3 | + array( |
|
| 4 | 4 | 'pretty_version' => 'dev-master', |
| 5 | 5 | 'version' => 'dev-master', |
| 6 | 6 | 'aliases' => |
| 7 | - array ( |
|
| 7 | + array( |
|
| 8 | 8 | ), |
| 9 | 9 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
| 10 | 10 | 'name' => 'ayecode/invoicing', |
| 11 | 11 | ), |
| 12 | 12 | 'versions' => |
| 13 | - array ( |
|
| 13 | + array( |
|
| 14 | 14 | 'ayecode/ayecode-connect-helper' => |
| 15 | - array ( |
|
| 15 | + array( |
|
| 16 | 16 | 'pretty_version' => '1.0.3', |
| 17 | 17 | 'version' => '1.0.3.0', |
| 18 | 18 | 'aliases' => |
| 19 | - array ( |
|
| 19 | + array( |
|
| 20 | 20 | ), |
| 21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
| 22 | 22 | ), |
| 23 | 23 | 'ayecode/invoicing' => |
| 24 | - array ( |
|
| 24 | + array( |
|
| 25 | 25 | 'pretty_version' => 'dev-master', |
| 26 | 26 | 'version' => 'dev-master', |
| 27 | 27 | 'aliases' => |
| 28 | - array ( |
|
| 28 | + array( |
|
| 29 | 29 | ), |
| 30 | 30 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
| 31 | 31 | ), |
| 32 | 32 | 'ayecode/wp-ayecode-ui' => |
| 33 | - array ( |
|
| 33 | + array( |
|
| 34 | 34 | 'pretty_version' => '0.1.49', |
| 35 | 35 | 'version' => '0.1.49.0', |
| 36 | 36 | 'aliases' => |
| 37 | - array ( |
|
| 37 | + array( |
|
| 38 | 38 | ), |
| 39 | 39 | 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
| 40 | 40 | ), |
| 41 | 41 | 'ayecode/wp-font-awesome-settings' => |
| 42 | - array ( |
|
| 42 | + array( |
|
| 43 | 43 | 'pretty_version' => '1.0.12', |
| 44 | 44 | 'version' => '1.0.12.0', |
| 45 | 45 | 'aliases' => |
| 46 | - array ( |
|
| 46 | + array( |
|
| 47 | 47 | ), |
| 48 | 48 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
| 49 | 49 | ), |
| 50 | 50 | 'ayecode/wp-super-duper' => |
| 51 | - array ( |
|
| 51 | + array( |
|
| 52 | 52 | 'pretty_version' => '1.0.26', |
| 53 | 53 | 'version' => '1.0.26.0', |
| 54 | 54 | 'aliases' => |
| 55 | - array ( |
|
| 55 | + array( |
|
| 56 | 56 | ), |
| 57 | 57 | 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
| 58 | 58 | ), |
| 59 | 59 | 'composer/installers' => |
| 60 | - array ( |
|
| 60 | + array( |
|
| 61 | 61 | 'pretty_version' => 'v1.11.0', |
| 62 | 62 | 'version' => '1.11.0.0', |
| 63 | 63 | 'aliases' => |
| 64 | - array ( |
|
| 64 | + array( |
|
| 65 | 65 | ), |
| 66 | 66 | 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
| 67 | 67 | ), |
| 68 | 68 | 'maxmind-db/reader' => |
| 69 | - array ( |
|
| 69 | + array( |
|
| 70 | 70 | 'pretty_version' => 'v1.6.0', |
| 71 | 71 | 'version' => '1.6.0.0', |
| 72 | 72 | 'aliases' => |
| 73 | - array ( |
|
| 73 | + array( |
|
| 74 | 74 | ), |
| 75 | 75 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
| 76 | 76 | ), |
| 77 | 77 | 'roundcube/plugin-installer' => |
| 78 | - array ( |
|
| 78 | + array( |
|
| 79 | 79 | 'replaced' => |
| 80 | - array ( |
|
| 80 | + array( |
|
| 81 | 81 | 0 => '*', |
| 82 | 82 | ), |
| 83 | 83 | ), |
| 84 | 84 | 'shama/baton' => |
| 85 | - array ( |
|
| 85 | + array( |
|
| 86 | 86 | 'replaced' => |
| 87 | - array ( |
|
| 87 | + array( |
|
| 88 | 88 | 0 => '*', |
| 89 | 89 | ), |
| 90 | 90 | ), |
@@ -4,29 +4,29 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | $gateways = wpinv_get_payment_gateways(); |
| 10 | -ksort( $gateways ); |
|
| 10 | +ksort($gateways); |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | <div class="table-responsive"> |
| 14 | 14 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
| 15 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
| 15 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
| 16 | 16 | |
| 17 | 17 | <thead> |
| 18 | 18 | <tr class="table-light"> |
| 19 | 19 | |
| 20 | 20 | <th scope="col" class="border-bottom border-top text-left"> |
| 21 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
| 21 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
| 22 | 22 | </th> |
| 23 | 23 | |
| 24 | 24 | <th scope="col" class="border-bottom border-top text-center"> |
| 25 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
| 25 | + <?php _e('Enabled', 'invoicing'); ?> |
|
| 26 | 26 | </th> |
| 27 | 27 | |
| 28 | 28 | <th scope="col" class="border-bottom border-top text-center"> |
| 29 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
| 29 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
| 30 | 30 | </th> |
| 31 | 31 | |
| 32 | 32 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | </thead> |
| 36 | 36 | |
| 37 | 37 | <tbody> |
| 38 | - <?php foreach ( $gateways as $id => $gateway ) : ?> |
|
| 38 | + <?php foreach ($gateways as $id => $gateway) : ?> |
|
| 39 | 39 | <tr> |
| 40 | 40 | <td class="getpaid-payment-method text-left"> |
| 41 | - <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo sanitize_text_field( $gateway['admin_label'] ); ?></a> |
|
| 41 | + <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo sanitize_text_field($gateway['admin_label']); ?></a> |
|
| 42 | 42 | </td> |
| 43 | 43 | <td class="getpaid-payment-method-enabled text-center"> |
| 44 | 44 | <?php |
| 45 | 45 | |
| 46 | - if ( wpinv_is_gateway_active( $id ) ) { |
|
| 46 | + if (wpinv_is_gateway_active($id)) { |
|
| 47 | 47 | echo "<i class='text-success fa fa-check'></i>"; |
| 48 | 48 | } else { |
| 49 | 49 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | <td class="getpaid-payment-method-subscription text-center"> |
| 55 | 55 | <?php |
| 56 | 56 | |
| 57 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
| 58 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
| 57 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
| 58 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
| 59 | 59 | |
| 60 | - if ( $supports ) { |
|
| 60 | + if ($supports) { |
|
| 61 | 61 | echo "<i class='text-success fa fa-check'></i>"; |
| 62 | 62 | } else { |
| 63 | 63 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | </td> |
| 68 | 68 | |
| 69 | 69 | <td class="getpaid-payment-method-action text-right"> |
| 70 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
| 70 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
| 71 | 71 | </td> |
| 72 | 72 | |
| 73 | 73 | </tr> |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | <tfoot> |
| 78 | 78 | <tr class="table-light"> |
| 79 | 79 | <td colspan="4" class="border-top"> |
| 80 | - <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>"> |
|
| 81 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
| 80 | + <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>"> |
|
| 81 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
| 82 | 82 | </a> |
| 83 | 83 | </td> |
| 84 | 84 | </tr> |
@@ -13,94 +13,94 @@ discard block |
||
| 13 | 13 | class GetPaid_Paypal_Gateway extends GetPaid_Payment_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 = 'paypal'; |
| 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', 'single_subscription_group' ); |
| 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 = 1; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Stores line items to send to PayPal. |
|
| 38 | - * |
|
| 39 | - * @var array |
|
| 40 | - */ |
|
| 37 | + * Stores line items to send to PayPal. |
|
| 38 | + * |
|
| 39 | + * @var array |
|
| 40 | + */ |
|
| 41 | 41 | protected $line_items = array(); |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Endpoint for requests from PayPal. |
|
| 45 | - * |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - protected $notify_url; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Endpoint for requests to PayPal. |
|
| 52 | - * |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 44 | + * Endpoint for requests from PayPal. |
|
| 45 | + * |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + protected $notify_url; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Endpoint for requests to PayPal. |
|
| 52 | + * |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | 55 | protected $endpoint; |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * Currencies this gateway is allowed for. |
|
| 59 | - * |
|
| 60 | - * @var array |
|
| 61 | - */ |
|
| 62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 58 | + * Currencies this gateway is allowed for. |
|
| 59 | + * |
|
| 60 | + * @var array |
|
| 61 | + */ |
|
| 62 | + public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * URL to view a transaction. |
|
| 66 | - * |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 65 | + * URL to view a transaction. |
|
| 66 | + * |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | 69 | public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s'; |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * URL to view a subscription. |
|
| 73 | - * |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
| 72 | + * URL to view a subscription. |
|
| 73 | + * |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Class constructor. |
|
| 80 | - */ |
|
| 81 | - public function __construct() { |
|
| 79 | + * Class constructor. |
|
| 80 | + */ |
|
| 81 | + public function __construct() { |
|
| 82 | 82 | |
| 83 | 83 | $this->title = __( 'PayPal Standard', 'invoicing' ); |
| 84 | 84 | $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
| 85 | 85 | $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
| 86 | 86 | $this->notify_url = wpinv_get_ipn_url( $this->id ); |
| 87 | 87 | |
| 88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 88 | + add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 89 | 89 | add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
| 90 | 90 | |
| 91 | 91 | parent::__construct(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * Process Payment. |
|
| 96 | - * |
|
| 97 | - * |
|
| 98 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 99 | - * @param array $submission_data Posted checkout fields. |
|
| 100 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 101 | - * @return array |
|
| 102 | - */ |
|
| 103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 95 | + * Process Payment. |
|
| 96 | + * |
|
| 97 | + * |
|
| 98 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 99 | + * @param array $submission_data Posted checkout fields. |
|
| 100 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 101 | + * @return array |
|
| 102 | + */ |
|
| 103 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 104 | 104 | |
| 105 | 105 | // Get redirect url. |
| 106 | 106 | $paypal_redirect = $this->get_request_url( $invoice ); |
@@ -123,15 +123,15 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * Get the PayPal request URL for an invoice. |
|
| 127 | - * |
|
| 128 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - public function get_request_url( $invoice ) { |
|
| 126 | + * Get the PayPal request URL for an invoice. |
|
| 127 | + * |
|
| 128 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + public function get_request_url( $invoice ) { |
|
| 132 | 132 | |
| 133 | 133 | // Endpoint for this request |
| 134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 134 | + $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 135 | 135 | |
| 136 | 136 | // Retrieve paypal args. |
| 137 | 137 | $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
@@ -144,44 +144,44 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | return add_query_arg( $paypal_args, $this->endpoint ); |
| 146 | 146 | |
| 147 | - } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Get PayPal Args for passing to PP. |
|
| 151 | - * |
|
| 152 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 153 | - * @return array |
|
| 154 | - */ |
|
| 155 | - protected function get_paypal_args( $invoice ) { |
|
| 150 | + * Get PayPal Args for passing to PP. |
|
| 151 | + * |
|
| 152 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 153 | + * @return array |
|
| 154 | + */ |
|
| 155 | + protected function get_paypal_args( $invoice ) { |
|
| 156 | 156 | |
| 157 | 157 | // Whether or not to send the line items as one item. |
| 158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice ); |
|
| 159 | - |
|
| 160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 161 | - $force_one_line_item = true; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $paypal_args = apply_filters( |
|
| 165 | - 'getpaid_paypal_args', |
|
| 166 | - array_merge( |
|
| 167 | - $this->get_transaction_args( $invoice ), |
|
| 168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 169 | - ), |
|
| 170 | - $invoice |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 158 | + $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice ); |
|
| 159 | + |
|
| 160 | + if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 161 | + $force_one_line_item = true; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $paypal_args = apply_filters( |
|
| 165 | + 'getpaid_paypal_args', |
|
| 166 | + array_merge( |
|
| 167 | + $this->get_transaction_args( $invoice ), |
|
| 168 | + $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 169 | + ), |
|
| 170 | + $invoice |
|
| 171 | + ); |
|
| 172 | + |
|
| 173 | + return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Get transaction args for paypal request. |
|
| 178 | - * |
|
| 179 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | - * @return array |
|
| 181 | - */ |
|
| 182 | - protected function get_transaction_args( $invoice ) { |
|
| 183 | - |
|
| 184 | - return array( |
|
| 177 | + * Get transaction args for paypal request. |
|
| 178 | + * |
|
| 179 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | + * @return array |
|
| 181 | + */ |
|
| 182 | + protected function get_transaction_args( $invoice ) { |
|
| 183 | + |
|
| 184 | + return array( |
|
| 185 | 185 | 'cmd' => '_cart', |
| 186 | 186 | 'business' => wpinv_get_option( 'paypal_email', false ), |
| 187 | 187 | 'no_shipping' => '1', |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | - * Get line item args for paypal request. |
|
| 210 | - * |
|
| 211 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 212 | - * @param bool $force_one_line_item Create only one item for this invoice. |
|
| 213 | - * @return array |
|
| 214 | - */ |
|
| 215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 209 | + * Get line item args for paypal request. |
|
| 210 | + * |
|
| 211 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 212 | + * @param bool $force_one_line_item Create only one item for this invoice. |
|
| 213 | + * @return array |
|
| 214 | + */ |
|
| 215 | + protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 216 | 216 | |
| 217 | 217 | // Maybe send invoice as a single item. |
| 218 | - if ( $force_one_line_item ) { |
|
| 218 | + if ( $force_one_line_item ) { |
|
| 219 | 219 | return $this->get_line_item_args_single_item( $invoice ); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -235,129 +235,129 @@ discard block |
||
| 235 | 235 | $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 238 | + return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * Get line item args for paypal request as a single line item. |
|
| 244 | - * |
|
| 245 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 246 | - * @return array |
|
| 247 | - */ |
|
| 248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
| 249 | - $this->delete_line_items(); |
|
| 243 | + * Get line item args for paypal request as a single line item. |
|
| 244 | + * |
|
| 245 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 246 | + * @return array |
|
| 247 | + */ |
|
| 248 | + protected function get_line_item_args_single_item( $invoice ) { |
|
| 249 | + $this->delete_line_items(); |
|
| 250 | 250 | |
| 251 | 251 | $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
| 252 | - $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() ); |
|
| 252 | + $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() ); |
|
| 253 | 253 | |
| 254 | - return $this->get_line_items(); |
|
| 254 | + return $this->get_line_items(); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * Return all line items. |
|
| 259 | - */ |
|
| 260 | - protected function get_line_items() { |
|
| 261 | - return $this->line_items; |
|
| 262 | - } |
|
| 258 | + * Return all line items. |
|
| 259 | + */ |
|
| 260 | + protected function get_line_items() { |
|
| 261 | + return $this->line_items; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Remove all line items. |
|
| 266 | - */ |
|
| 267 | - protected function delete_line_items() { |
|
| 268 | - $this->line_items = array(); |
|
| 265 | + * Remove all line items. |
|
| 266 | + */ |
|
| 267 | + protected function delete_line_items() { |
|
| 268 | + $this->line_items = array(); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | - * Prepare line items to send to paypal. |
|
| 273 | - * |
|
| 274 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 275 | - */ |
|
| 276 | - protected function prepare_line_items( $invoice ) { |
|
| 277 | - $this->delete_line_items(); |
|
| 278 | - |
|
| 279 | - // Items. |
|
| 280 | - foreach ( $invoice->get_items() as $item ) { |
|
| 281 | - $amount = $item->get_price(); |
|
| 282 | - $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
| 283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 272 | + * Prepare line items to send to paypal. |
|
| 273 | + * |
|
| 274 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 275 | + */ |
|
| 276 | + protected function prepare_line_items( $invoice ) { |
|
| 277 | + $this->delete_line_items(); |
|
| 278 | + |
|
| 279 | + // Items. |
|
| 280 | + foreach ( $invoice->get_items() as $item ) { |
|
| 281 | + $amount = $item->get_price(); |
|
| 282 | + $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
| 283 | + $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Fees. |
| 287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 287 | + foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 288 | 288 | $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | - * Add PayPal Line Item. |
|
| 295 | - * |
|
| 296 | - * @param string $item_name Item name. |
|
| 297 | - * @param float $quantity Item quantity. |
|
| 298 | - * @param float $amount Amount. |
|
| 299 | - * @param string $item_number Item number. |
|
| 300 | - */ |
|
| 301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 303 | - |
|
| 304 | - $item = apply_filters( |
|
| 305 | - 'getpaid_paypal_line_item', |
|
| 306 | - array( |
|
| 307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 308 | - 'quantity' => (float) $quantity, |
|
| 309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 310 | - 'item_number' => $item_number, |
|
| 311 | - ), |
|
| 312 | - $item_name, |
|
| 313 | - $quantity, |
|
| 314 | - $amount, |
|
| 315 | - $item_number |
|
| 316 | - ); |
|
| 317 | - |
|
| 318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 294 | + * Add PayPal Line Item. |
|
| 295 | + * |
|
| 296 | + * @param string $item_name Item name. |
|
| 297 | + * @param float $quantity Item quantity. |
|
| 298 | + * @param float $amount Amount. |
|
| 299 | + * @param string $item_number Item number. |
|
| 300 | + */ |
|
| 301 | + protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | + $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 303 | + |
|
| 304 | + $item = apply_filters( |
|
| 305 | + 'getpaid_paypal_line_item', |
|
| 306 | + array( |
|
| 307 | + 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 308 | + 'quantity' => (float) $quantity, |
|
| 309 | + 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 310 | + 'item_number' => $item_number, |
|
| 311 | + ), |
|
| 312 | + $item_name, |
|
| 313 | + $quantity, |
|
| 314 | + $amount, |
|
| 315 | + $item_number |
|
| 316 | + ); |
|
| 317 | + |
|
| 318 | + $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 319 | 319 | $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
| 320 | 320 | |
| 321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
| 322 | - $this->line_items[ 'amount_' . $index ] = $item['amount'] * $item['quantity']; |
|
| 323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 322 | + $this->line_items[ 'amount_' . $index ] = $item['amount'] * $item['quantity']; |
|
| 323 | + $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | - * If the default request with line items is too long, generate a new one with only one line item. |
|
| 328 | - * |
|
| 329 | - * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
| 330 | - * |
|
| 331 | - * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
| 332 | - * @param array $paypal_args Arguments sent to Paypal in the request. |
|
| 333 | - * @return array |
|
| 334 | - */ |
|
| 335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 336 | - $max_paypal_length = 2083; |
|
| 337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 338 | - |
|
| 339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 340 | - return $paypal_args; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return apply_filters( |
|
| 344 | - 'getpaid_paypal_args', |
|
| 345 | - array_merge( |
|
| 346 | - $this->get_transaction_args( $invoice ), |
|
| 347 | - $this->get_line_item_args( $invoice, true ) |
|
| 348 | - ), |
|
| 349 | - $invoice |
|
| 350 | - ); |
|
| 327 | + * If the default request with line items is too long, generate a new one with only one line item. |
|
| 328 | + * |
|
| 329 | + * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
| 330 | + * |
|
| 331 | + * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
| 332 | + * @param array $paypal_args Arguments sent to Paypal in the request. |
|
| 333 | + * @return array |
|
| 334 | + */ |
|
| 335 | + protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 336 | + $max_paypal_length = 2083; |
|
| 337 | + $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 338 | + |
|
| 339 | + if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 340 | + return $paypal_args; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return apply_filters( |
|
| 344 | + 'getpaid_paypal_args', |
|
| 345 | + array_merge( |
|
| 346 | + $this->get_transaction_args( $invoice ), |
|
| 347 | + $this->get_line_item_args( $invoice, true ) |
|
| 348 | + ), |
|
| 349 | + $invoice |
|
| 350 | + ); |
|
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | - * Processes recurring invoices. |
|
| 356 | - * |
|
| 357 | - * @param array $paypal_args PayPal args. |
|
| 358 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 359 | - */ |
|
| 360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
| 355 | + * Processes recurring invoices. |
|
| 356 | + * |
|
| 357 | + * @param array $paypal_args PayPal args. |
|
| 358 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 359 | + */ |
|
| 360 | + public function process_subscription( $paypal_args, $invoice ) { |
|
| 361 | 361 | |
| 362 | 362 | // Make sure this is a subscription. |
| 363 | 363 | if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) { |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
| 384 | 384 | |
| 385 | - // Trial period length. |
|
| 386 | - $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
| 385 | + // Trial period length. |
|
| 386 | + $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
| 387 | 387 | |
| 388 | - // Trial period. |
|
| 389 | - $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
| 388 | + // Trial period. |
|
| 389 | + $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
| 390 | 390 | |
| 391 | 391 | } else if ( $initial_amount != $recurring_amount ) { |
| 392 | 392 | |
@@ -409,40 +409,40 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // We have a recurring payment |
| 412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 412 | + if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 413 | 413 | |
| 414 | - // Subscription price |
|
| 415 | - $paypal_args['a3'] = $recurring_amount; |
|
| 414 | + // Subscription price |
|
| 415 | + $paypal_args['a3'] = $recurring_amount; |
|
| 416 | 416 | |
| 417 | - // Subscription duration |
|
| 418 | - $paypal_args['p3'] = $interval; |
|
| 417 | + // Subscription duration |
|
| 418 | + $paypal_args['p3'] = $interval; |
|
| 419 | 419 | |
| 420 | - // Subscription period |
|
| 421 | - $paypal_args['t3'] = $period; |
|
| 420 | + // Subscription period |
|
| 421 | + $paypal_args['t3'] = $period; |
|
| 422 | 422 | |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Recurring payments |
| 426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 426 | + if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 427 | 427 | |
| 428 | - // Non-recurring payments |
|
| 429 | - $paypal_args['src'] = 0; |
|
| 428 | + // Non-recurring payments |
|
| 429 | + $paypal_args['src'] = 0; |
|
| 430 | 430 | |
| 431 | - } else { |
|
| 431 | + } else { |
|
| 432 | 432 | |
| 433 | - $paypal_args['src'] = 1; |
|
| 433 | + $paypal_args['src'] = 1; |
|
| 434 | 434 | |
| 435 | - if ( $bill_times > 0 ) { |
|
| 435 | + if ( $bill_times > 0 ) { |
|
| 436 | 436 | |
| 437 | - // An initial period is being used to charge a sign-up fee |
|
| 438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 439 | - $bill_times--; |
|
| 440 | - } |
|
| 437 | + // An initial period is being used to charge a sign-up fee |
|
| 438 | + if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 439 | + $bill_times--; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | // Make sure it's not over the max of 52 |
| 443 | 443 | $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
| 444 | 444 | |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | // Force return URL so that order description & instructions display |
@@ -458,19 +458,19 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return apply_filters( |
| 461 | - 'getpaid_paypal_subscription_args', |
|
| 462 | - $paypal_args, |
|
| 463 | - $invoice |
|
| 461 | + 'getpaid_paypal_subscription_args', |
|
| 462 | + $paypal_args, |
|
| 463 | + $invoice |
|
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | - * Processes ipns and marks payments as complete. |
|
| 470 | - * |
|
| 471 | - * @return void |
|
| 472 | - */ |
|
| 473 | - public function verify_ipn() { |
|
| 469 | + * Processes ipns and marks payments as complete. |
|
| 470 | + * |
|
| 471 | + * @return void |
|
| 472 | + */ |
|
| 473 | + public function verify_ipn() { |
|
| 474 | 474 | new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
| 475 | 475 | } |
| 476 | 476 | |
@@ -480,19 +480,19 @@ discard block |
||
| 480 | 480 | public function sandbox_notice() { |
| 481 | 481 | |
| 482 | 482 | return sprintf( |
| 483 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 484 | - '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
|
| 485 | - '</a>' |
|
| 486 | - ); |
|
| 483 | + __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 484 | + '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
|
| 485 | + '</a>' |
|
| 486 | + ); |
|
| 487 | 487 | |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - /** |
|
| 491 | - * Filters the gateway settings. |
|
| 492 | - * |
|
| 493 | - * @param array $admin_settings |
|
| 494 | - */ |
|
| 495 | - public function admin_settings( $admin_settings ) { |
|
| 490 | + /** |
|
| 491 | + * Filters the gateway settings. |
|
| 492 | + * |
|
| 493 | + * @param array $admin_settings |
|
| 494 | + */ |
|
| 495 | + public function admin_settings( $admin_settings ) { |
|
| 496 | 496 | |
| 497 | 497 | $currencies = sprintf( |
| 498 | 498 | __( 'Supported Currencies: %s', 'invoicing' ), |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | 'readonly' => true, |
| 519 | 519 | ); |
| 520 | 520 | |
| 521 | - return $admin_settings; |
|
| 522 | - } |
|
| 521 | + return $admin_settings; |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | 524 | } |
@@ -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 | * Paypal Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' ); |
|
| 27 | + protected $supports = array('subscription', 'sandbox', 'single_subscription_group'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @var array |
| 61 | 61 | */ |
| 62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 62 | + public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR'); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * URL to view a transaction. |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function __construct() { |
| 82 | 82 | |
| 83 | - $this->title = __( 'PayPal Standard', 'invoicing' ); |
|
| 84 | - $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
|
| 85 | - $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
|
| 86 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
| 83 | + $this->title = __('PayPal Standard', 'invoicing'); |
|
| 84 | + $this->method_title = __('PayPal Standard', 'invoicing'); |
|
| 85 | + $this->checkout_button_text = __('Proceed to PayPal', 'invoicing'); |
|
| 86 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
| 87 | 87 | |
| 88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 89 | - add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
| 88 | + add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2); |
|
| 89 | + add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice')); |
|
| 90 | 90 | |
| 91 | 91 | parent::__construct(); |
| 92 | 92 | } |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 101 | 101 | * @return array |
| 102 | 102 | */ |
| 103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 103 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 104 | 104 | |
| 105 | 105 | // Get redirect url. |
| 106 | - $paypal_redirect = $this->get_request_url( $invoice ); |
|
| 106 | + $paypal_redirect = $this->get_request_url($invoice); |
|
| 107 | 107 | |
| 108 | 108 | // Add a note about the request url. |
| 109 | 109 | $invoice->add_note( |
| 110 | 110 | sprintf( |
| 111 | - __( 'Redirecting to PayPal: %s', 'invoicing' ), |
|
| 112 | - esc_url( $paypal_redirect ) |
|
| 111 | + __('Redirecting to PayPal: %s', 'invoicing'), |
|
| 112 | + esc_url($paypal_redirect) |
|
| 113 | 113 | ), |
| 114 | 114 | false, |
| 115 | 115 | false, |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | // Redirect to PayPal |
| 120 | - wp_redirect( $paypal_redirect ); |
|
| 120 | + wp_redirect($paypal_redirect); |
|
| 121 | 121 | exit; |
| 122 | 122 | |
| 123 | 123 | } |
@@ -128,21 +128,21 @@ discard block |
||
| 128 | 128 | * @param WPInv_Invoice $invoice Invoice object. |
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | - public function get_request_url( $invoice ) { |
|
| 131 | + public function get_request_url($invoice) { |
|
| 132 | 132 | |
| 133 | 133 | // Endpoint for this request |
| 134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 134 | + $this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 135 | 135 | |
| 136 | 136 | // Retrieve paypal args. |
| 137 | - $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
|
| 137 | + $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode'); |
|
| 138 | 138 | |
| 139 | - if ( $invoice->is_recurring() ) { |
|
| 139 | + if ($invoice->is_recurring()) { |
|
| 140 | 140 | $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US'; |
| 141 | 141 | } else { |
| 142 | 142 | $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US'; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return add_query_arg( $paypal_args, $this->endpoint ); |
|
| 145 | + return add_query_arg($paypal_args, $this->endpoint); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -152,25 +152,25 @@ discard block |
||
| 152 | 152 | * @param WPInv_Invoice $invoice Invoice object. |
| 153 | 153 | * @return array |
| 154 | 154 | */ |
| 155 | - protected function get_paypal_args( $invoice ) { |
|
| 155 | + protected function get_paypal_args($invoice) { |
|
| 156 | 156 | |
| 157 | 157 | // Whether or not to send the line items as one item. |
| 158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice ); |
|
| 158 | + $force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice); |
|
| 159 | 159 | |
| 160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 160 | + if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) { |
|
| 161 | 161 | $force_one_line_item = true; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $paypal_args = apply_filters( |
| 165 | 165 | 'getpaid_paypal_args', |
| 166 | 166 | array_merge( |
| 167 | - $this->get_transaction_args( $invoice ), |
|
| 168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 167 | + $this->get_transaction_args($invoice), |
|
| 168 | + $this->get_line_item_args($invoice, $force_one_line_item) |
|
| 169 | 169 | ), |
| 170 | 170 | $invoice |
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 173 | + return $this->fix_request_length($invoice, $paypal_args); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | * @param WPInv_Invoice $invoice Invoice object. |
| 180 | 180 | * @return array |
| 181 | 181 | */ |
| 182 | - protected function get_transaction_args( $invoice ) { |
|
| 182 | + protected function get_transaction_args($invoice) { |
|
| 183 | 183 | |
| 184 | 184 | return array( |
| 185 | 185 | 'cmd' => '_cart', |
| 186 | - 'business' => wpinv_get_option( 'paypal_email', false ), |
|
| 186 | + 'business' => wpinv_get_option('paypal_email', false), |
|
| 187 | 187 | 'no_shipping' => '1', |
| 188 | 188 | 'shipping' => '0', |
| 189 | 189 | 'no_note' => '1', |
@@ -191,16 +191,16 @@ discard block |
||
| 191 | 191 | 'rm' => is_ssl() ? 2 : 1, |
| 192 | 192 | 'upload' => 1, |
| 193 | 193 | 'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal |
| 194 | - 'return' => esc_url_raw( $this->get_return_url( $invoice ) ), |
|
| 195 | - 'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ), |
|
| 196 | - 'notify_url' => getpaid_limit_length( $this->notify_url, 255 ), |
|
| 197 | - 'invoice' => getpaid_limit_length( $invoice->get_number(), 127 ), |
|
| 194 | + 'return' => esc_url_raw($this->get_return_url($invoice)), |
|
| 195 | + 'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()), |
|
| 196 | + 'notify_url' => getpaid_limit_length($this->notify_url, 255), |
|
| 197 | + 'invoice' => getpaid_limit_length($invoice->get_number(), 127), |
|
| 198 | 198 | 'custom' => $invoice->get_id(), |
| 199 | - 'first_name' => getpaid_limit_length( $invoice->get_first_name(), 32 ), |
|
| 200 | - 'last_name' => getpaid_limit_length( $invoice->get_last_name(), 64 ), |
|
| 201 | - 'country' => getpaid_limit_length( $invoice->get_country(), 2 ), |
|
| 202 | - 'email' => getpaid_limit_length( $invoice->get_email(), 127 ), |
|
| 203 | - 'cbt' => get_bloginfo( 'name' ) |
|
| 199 | + 'first_name' => getpaid_limit_length($invoice->get_first_name(), 32), |
|
| 200 | + 'last_name' => getpaid_limit_length($invoice->get_last_name(), 64), |
|
| 201 | + 'country' => getpaid_limit_length($invoice->get_country(), 2), |
|
| 202 | + 'email' => getpaid_limit_length($invoice->get_email(), 127), |
|
| 203 | + 'cbt' => get_bloginfo('name') |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | } |
@@ -212,30 +212,30 @@ discard block |
||
| 212 | 212 | * @param bool $force_one_line_item Create only one item for this invoice. |
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 215 | + protected function get_line_item_args($invoice, $force_one_line_item = false) { |
|
| 216 | 216 | |
| 217 | 217 | // Maybe send invoice as a single item. |
| 218 | - if ( $force_one_line_item ) { |
|
| 219 | - return $this->get_line_item_args_single_item( $invoice ); |
|
| 218 | + if ($force_one_line_item) { |
|
| 219 | + return $this->get_line_item_args_single_item($invoice); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // Send each line item individually. |
| 223 | 223 | $line_item_args = array(); |
| 224 | 224 | |
| 225 | 225 | // Prepare line items. |
| 226 | - $this->prepare_line_items( $invoice ); |
|
| 226 | + $this->prepare_line_items($invoice); |
|
| 227 | 227 | |
| 228 | 228 | // Add taxes to the cart |
| 229 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
| 230 | - $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 ); |
|
| 229 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
| 230 | + $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Add discount. |
| 234 | - if ( $invoice->get_total_discount() > 0 ) { |
|
| 235 | - $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
|
| 234 | + if ($invoice->get_total_discount() > 0) { |
|
| 235 | + $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 238 | + return array_merge($line_item_args, $this->get_line_items()); |
|
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
@@ -245,11 +245,11 @@ discard block |
||
| 245 | 245 | * @param WPInv_Invoice $invoice Invoice object. |
| 246 | 246 | * @return array |
| 247 | 247 | */ |
| 248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
| 248 | + protected function get_line_item_args_single_item($invoice) { |
|
| 249 | 249 | $this->delete_line_items(); |
| 250 | 250 | |
| 251 | - $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 252 | - $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() ); |
|
| 251 | + $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 252 | + $this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id()); |
|
| 253 | 253 | |
| 254 | 254 | return $this->get_line_items(); |
| 255 | 255 | } |
@@ -273,19 +273,19 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @param WPInv_Invoice $invoice Invoice object. |
| 275 | 275 | */ |
| 276 | - protected function prepare_line_items( $invoice ) { |
|
| 276 | + protected function prepare_line_items($invoice) { |
|
| 277 | 277 | $this->delete_line_items(); |
| 278 | 278 | |
| 279 | 279 | // Items. |
| 280 | - foreach ( $invoice->get_items() as $item ) { |
|
| 280 | + foreach ($invoice->get_items() as $item) { |
|
| 281 | 281 | $amount = $item->get_price(); |
| 282 | 282 | $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
| 283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 283 | + $this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id()); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Fees. |
| 287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 288 | - $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
|
| 287 | + foreach ($invoice->get_fees() as $fee => $data) { |
|
| 288 | + $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee'])); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
@@ -298,15 +298,15 @@ discard block |
||
| 298 | 298 | * @param float $amount Amount. |
| 299 | 299 | * @param string $item_number Item number. |
| 300 | 300 | */ |
| 301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 301 | + protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') { |
|
| 302 | + $index = (count($this->line_items) / 4) + 1; |
|
| 303 | 303 | |
| 304 | 304 | $item = apply_filters( |
| 305 | 305 | 'getpaid_paypal_line_item', |
| 306 | 306 | array( |
| 307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 307 | + 'item_name' => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'), |
|
| 308 | 308 | 'quantity' => (float) $quantity, |
| 309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 309 | + 'amount' => wpinv_sanitize_amount((float) $amount, 2), |
|
| 310 | 310 | 'item_number' => $item_number, |
| 311 | 311 | ), |
| 312 | 312 | $item_name, |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | $item_number |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 319 | - $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
|
| 318 | + $this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127); |
|
| 319 | + $this->line_items['quantity_' . $index] = $item['quantity']; |
|
| 320 | 320 | |
| 321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
| 322 | - $this->line_items[ 'amount_' . $index ] = $item['amount'] * $item['quantity']; |
|
| 323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 322 | + $this->line_items['amount_' . $index] = $item['amount'] * $item['quantity']; |
|
| 323 | + $this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * @param array $paypal_args Arguments sent to Paypal in the request. |
| 333 | 333 | * @return array |
| 334 | 334 | */ |
| 335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 335 | + protected function fix_request_length($invoice, $paypal_args) { |
|
| 336 | 336 | $max_paypal_length = 2083; |
| 337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 337 | + $query_candidate = http_build_query($paypal_args, '', '&'); |
|
| 338 | 338 | |
| 339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 339 | + if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) { |
|
| 340 | 340 | return $paypal_args; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | return apply_filters( |
| 344 | 344 | 'getpaid_paypal_args', |
| 345 | 345 | array_merge( |
| 346 | - $this->get_transaction_args( $invoice ), |
|
| 347 | - $this->get_line_item_args( $invoice, true ) |
|
| 346 | + $this->get_transaction_args($invoice), |
|
| 347 | + $this->get_line_item_args($invoice, true) |
|
| 348 | 348 | ), |
| 349 | 349 | $invoice |
| 350 | 350 | ); |
@@ -357,10 +357,10 @@ discard block |
||
| 357 | 357 | * @param array $paypal_args PayPal args. |
| 358 | 358 | * @param WPInv_Invoice $invoice Invoice object. |
| 359 | 359 | */ |
| 360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
| 360 | + public function process_subscription($paypal_args, $invoice) { |
|
| 361 | 361 | |
| 362 | 362 | // Make sure this is a subscription. |
| 363 | - if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) { |
|
| 363 | + if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) { |
|
| 364 | 364 | return $paypal_args; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -368,17 +368,17 @@ discard block |
||
| 368 | 368 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
| 369 | 369 | |
| 370 | 370 | // Subscription name. |
| 371 | - $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 371 | + $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 372 | 372 | |
| 373 | 373 | // Get subscription args. |
| 374 | - $period = strtoupper( substr( $subscription->get_period(), 0, 1) ); |
|
| 374 | + $period = strtoupper(substr($subscription->get_period(), 0, 1)); |
|
| 375 | 375 | $interval = (int) $subscription->get_frequency(); |
| 376 | 376 | $bill_times = (int) $subscription->get_bill_times(); |
| 377 | - $initial_amount = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 ); |
|
| 378 | - $recurring_amount = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 ); |
|
| 379 | - $subscription_item = $invoice->get_recurring( true ); |
|
| 377 | + $initial_amount = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2); |
|
| 378 | + $recurring_amount = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2); |
|
| 379 | + $subscription_item = $invoice->get_recurring(true); |
|
| 380 | 380 | |
| 381 | - if ( $subscription_item->has_free_trial() ) { |
|
| 381 | + if ($subscription_item->has_free_trial()) { |
|
| 382 | 382 | |
| 383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
| 384 | 384 | |
@@ -388,28 +388,28 @@ discard block |
||
| 388 | 388 | // Trial period. |
| 389 | 389 | $paypal_args['t1'] = $subscription_item->get_trial_period(); |
| 390 | 390 | |
| 391 | - } else if ( $initial_amount != $recurring_amount ) { |
|
| 391 | + } else if ($initial_amount != $recurring_amount) { |
|
| 392 | 392 | |
| 393 | 393 | // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period. |
| 394 | 394 | |
| 395 | - if ( 1 == $bill_times ) { |
|
| 395 | + if (1 == $bill_times) { |
|
| 396 | 396 | $param_number = 3; |
| 397 | 397 | } else { |
| 398 | 398 | $param_number = 1; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0; |
|
| 401 | + $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0; |
|
| 402 | 402 | |
| 403 | 403 | // Sign Up interval |
| 404 | - $paypal_args[ 'p' . $param_number ] = $interval; |
|
| 404 | + $paypal_args['p' . $param_number] = $interval; |
|
| 405 | 405 | |
| 406 | 406 | // Sign Up unit of duration |
| 407 | - $paypal_args[ 't' . $param_number ] = $period; |
|
| 407 | + $paypal_args['t' . $param_number] = $period; |
|
| 408 | 408 | |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // We have a recurring payment |
| 412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 412 | + if (!isset($param_number) || 1 == $param_number) { |
|
| 413 | 413 | |
| 414 | 414 | // Subscription price |
| 415 | 415 | $paypal_args['a3'] = $recurring_amount; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Recurring payments |
| 426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 426 | + if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) { |
|
| 427 | 427 | |
| 428 | 428 | // Non-recurring payments |
| 429 | 429 | $paypal_args['src'] = 0; |
@@ -432,15 +432,15 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $paypal_args['src'] = 1; |
| 434 | 434 | |
| 435 | - if ( $bill_times > 0 ) { |
|
| 435 | + if ($bill_times > 0) { |
|
| 436 | 436 | |
| 437 | 437 | // An initial period is being used to charge a sign-up fee |
| 438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 438 | + if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) { |
|
| 439 | 439 | $bill_times--; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Make sure it's not over the max of 52 |
| 443 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
| 443 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
| 444 | 444 | |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | $paypal_args['rm'] = 2; |
| 450 | 450 | |
| 451 | 451 | // Get rid of redudant items. |
| 452 | - foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) { |
|
| 452 | + foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) { |
|
| 453 | 453 | |
| 454 | - if ( isset( $paypal_args[ $arg ] ) ) { |
|
| 455 | - unset( $paypal_args[ $arg ] ); |
|
| 454 | + if (isset($paypal_args[$arg])) { |
|
| 455 | + unset($paypal_args[$arg]); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @return void |
| 472 | 472 | */ |
| 473 | 473 | public function verify_ipn() { |
| 474 | - new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
|
| 474 | + new GetPaid_Paypal_Gateway_IPN_Handler($this); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | public function sandbox_notice() { |
| 481 | 481 | |
| 482 | 482 | return sprintf( |
| 483 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 483 | + __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
| 484 | 484 | '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
| 485 | 485 | '</a>' |
| 486 | 486 | ); |
@@ -492,29 +492,29 @@ discard block |
||
| 492 | 492 | * |
| 493 | 493 | * @param array $admin_settings |
| 494 | 494 | */ |
| 495 | - public function admin_settings( $admin_settings ) { |
|
| 495 | + public function admin_settings($admin_settings) { |
|
| 496 | 496 | |
| 497 | 497 | $currencies = sprintf( |
| 498 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
| 499 | - implode( ', ', $this->currencies ) |
|
| 498 | + __('Supported Currencies: %s', 'invoicing'), |
|
| 499 | + implode(', ', $this->currencies) |
|
| 500 | 500 | ); |
| 501 | 501 | |
| 502 | 502 | $admin_settings['paypal_active']['desc'] .= " ($currencies)"; |
| 503 | - $admin_settings['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
| 503 | + $admin_settings['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
| 504 | 504 | |
| 505 | 505 | $admin_settings['paypal_email'] = array( |
| 506 | 506 | 'type' => 'text', |
| 507 | 507 | 'id' => 'paypal_email', |
| 508 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
| 509 | - 'desc' => __( "Please enter your PayPal account's email address. Use your sandbox email address in case you've enabled sandbox above.", 'invoicing' ), |
|
| 508 | + 'name' => __('PayPal Email', 'invoicing'), |
|
| 509 | + 'desc' => __("Please enter your PayPal account's email address. Use your sandbox email address in case you've enabled sandbox above.", 'invoicing'), |
|
| 510 | 510 | ); |
| 511 | 511 | |
| 512 | 512 | $admin_settings['paypal_ipn_url'] = array( |
| 513 | 513 | 'type' => 'ipn_url', |
| 514 | 514 | 'id' => 'paypal_ipn_url', |
| 515 | - 'name' => __( 'IPN Url', 'invoicing' ), |
|
| 515 | + 'name' => __('IPN Url', 'invoicing'), |
|
| 516 | 516 | 'std' => $this->notify_url, |
| 517 | - 'desc' => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
| 517 | + 'desc' => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
| 518 | 518 | 'readonly' => true, |
| 519 | 519 | ); |
| 520 | 520 | |
@@ -13,464 +13,464 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | abstract class GetPaid_Payment_Gateway { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Set if the place checkout button should be renamed on selection. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $checkout_button_text; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Boolean whether the method is enabled. |
|
| 25 | - * |
|
| 26 | - * @var bool |
|
| 27 | - */ |
|
| 28 | - public $enabled = true; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Payment method id. |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public $id; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Payment method order. |
|
| 39 | - * |
|
| 40 | - * @var int |
|
| 41 | - */ |
|
| 42 | - public $order = 10; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Payment method title for the frontend. |
|
| 46 | - * |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 49 | - public $title; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Payment method description for the frontend. |
|
| 53 | - * |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - public $description; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Gateway title. |
|
| 60 | - * |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 63 | - public $method_title = ''; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Gateway description. |
|
| 67 | - * |
|
| 68 | - * @var string |
|
| 69 | - */ |
|
| 70 | - public $method_description = ''; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Countries this gateway is allowed for. |
|
| 74 | - * |
|
| 75 | - * @var array |
|
| 76 | - */ |
|
| 77 | - public $countries; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Currencies this gateway is allowed for. |
|
| 81 | - * |
|
| 82 | - * @var array |
|
| 83 | - */ |
|
| 84 | - public $currencies; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Currencies this gateway is not allowed for. |
|
| 88 | - * |
|
| 89 | - * @var array |
|
| 90 | - */ |
|
| 91 | - public $exclude_currencies; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Maximum transaction amount, zero does not define a maximum. |
|
| 95 | - * |
|
| 96 | - * @var int |
|
| 97 | - */ |
|
| 98 | - public $max_amount = 0; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Optional URL to view a transaction. |
|
| 102 | - * |
|
| 103 | - * @var string |
|
| 104 | - */ |
|
| 105 | - public $view_transaction_url = ''; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Optional URL to view a subscription. |
|
| 109 | - * |
|
| 110 | - * @var string |
|
| 111 | - */ |
|
| 112 | - public $view_subscription_url = ''; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Optional label to show for "new payment method" in the payment |
|
| 116 | - * method/token selection radio selection. |
|
| 117 | - * |
|
| 118 | - * @var string |
|
| 119 | - */ |
|
| 120 | - public $new_method_label = ''; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Contains a user's saved tokens for this gateway. |
|
| 124 | - * |
|
| 125 | - * @var array |
|
| 126 | - */ |
|
| 127 | - protected $tokens = array(); |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * An array of features that this gateway supports. |
|
| 131 | - * |
|
| 132 | - * @var array |
|
| 133 | - */ |
|
| 134 | - protected $supports = array(); |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Class constructor. |
|
| 138 | - */ |
|
| 139 | - public function __construct() { |
|
| 140 | - |
|
| 141 | - // Register gateway. |
|
| 142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 143 | - |
|
| 144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 145 | - |
|
| 146 | - // Add support for various features. |
|
| 147 | - foreach ( $this->supports as $feature ) { |
|
| 148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
| 149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
| 150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - // Invoice addons. |
|
| 154 | - if ( $this->supports( 'addons' ) ) { |
|
| 155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // Gateway settings. |
|
| 159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
| 16 | + /** |
|
| 17 | + * Set if the place checkout button should be renamed on selection. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $checkout_button_text; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Boolean whether the method is enabled. |
|
| 25 | + * |
|
| 26 | + * @var bool |
|
| 27 | + */ |
|
| 28 | + public $enabled = true; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Payment method id. |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public $id; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Payment method order. |
|
| 39 | + * |
|
| 40 | + * @var int |
|
| 41 | + */ |
|
| 42 | + public $order = 10; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Payment method title for the frontend. |
|
| 46 | + * |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | + public $title; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Payment method description for the frontend. |
|
| 53 | + * |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + public $description; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Gateway title. |
|
| 60 | + * |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | + public $method_title = ''; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Gateway description. |
|
| 67 | + * |
|
| 68 | + * @var string |
|
| 69 | + */ |
|
| 70 | + public $method_description = ''; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Countries this gateway is allowed for. |
|
| 74 | + * |
|
| 75 | + * @var array |
|
| 76 | + */ |
|
| 77 | + public $countries; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Currencies this gateway is allowed for. |
|
| 81 | + * |
|
| 82 | + * @var array |
|
| 83 | + */ |
|
| 84 | + public $currencies; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Currencies this gateway is not allowed for. |
|
| 88 | + * |
|
| 89 | + * @var array |
|
| 90 | + */ |
|
| 91 | + public $exclude_currencies; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Maximum transaction amount, zero does not define a maximum. |
|
| 95 | + * |
|
| 96 | + * @var int |
|
| 97 | + */ |
|
| 98 | + public $max_amount = 0; |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Optional URL to view a transaction. |
|
| 102 | + * |
|
| 103 | + * @var string |
|
| 104 | + */ |
|
| 105 | + public $view_transaction_url = ''; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Optional URL to view a subscription. |
|
| 109 | + * |
|
| 110 | + * @var string |
|
| 111 | + */ |
|
| 112 | + public $view_subscription_url = ''; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Optional label to show for "new payment method" in the payment |
|
| 116 | + * method/token selection radio selection. |
|
| 117 | + * |
|
| 118 | + * @var string |
|
| 119 | + */ |
|
| 120 | + public $new_method_label = ''; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Contains a user's saved tokens for this gateway. |
|
| 124 | + * |
|
| 125 | + * @var array |
|
| 126 | + */ |
|
| 127 | + protected $tokens = array(); |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * An array of features that this gateway supports. |
|
| 131 | + * |
|
| 132 | + * @var array |
|
| 133 | + */ |
|
| 134 | + protected $supports = array(); |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Class constructor. |
|
| 138 | + */ |
|
| 139 | + public function __construct() { |
|
| 140 | + |
|
| 141 | + // Register gateway. |
|
| 142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 143 | + |
|
| 144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 145 | + |
|
| 146 | + // Add support for various features. |
|
| 147 | + foreach ( $this->supports as $feature ) { |
|
| 148 | + add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
| 149 | + add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
| 150 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + // Invoice addons. |
|
| 154 | + if ( $this->supports( 'addons' ) ) { |
|
| 155 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // Gateway settings. |
|
| 159 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
| 160 | 160 | |
| 161 | 161 | |
| 162 | - // Gateway checkout fiellds. |
|
| 163 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 164 | - |
|
| 165 | - // Process payment. |
|
| 166 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 167 | - |
|
| 168 | - // Change the checkout button text. |
|
| 169 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
| 170 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - // Check if a gateway is valid for a given currency. |
|
| 174 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 175 | - |
|
| 176 | - // Generate the transaction url. |
|
| 177 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 178 | - |
|
| 179 | - // Generate the subscription url. |
|
| 180 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
| 181 | - |
|
| 182 | - // Confirm payments. |
|
| 183 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 184 | - |
|
| 185 | - // Verify IPNs. |
|
| 186 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 187 | - |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Checks if this gateway is a given gateway. |
|
| 192 | - * |
|
| 193 | - * @since 1.0.19 |
|
| 194 | - * @return bool |
|
| 195 | - */ |
|
| 196 | - public function is( $gateway ) { |
|
| 197 | - return $gateway == $this->id; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Returns a users saved tokens for this gateway. |
|
| 202 | - * |
|
| 203 | - * @since 1.0.19 |
|
| 204 | - * @return array |
|
| 205 | - */ |
|
| 206 | - public function get_tokens( $sandbox = null ) { |
|
| 207 | - |
|
| 208 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
| 209 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 210 | - |
|
| 211 | - if ( is_array( $tokens ) ) { |
|
| 212 | - $this->tokens = $tokens; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - if ( ! is_bool( $sandbox ) ) { |
|
| 218 | - return $this->tokens; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // Filter tokens. |
|
| 222 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
| 223 | - return wp_list_filter( $this->tokens, $args ); |
|
| 224 | - |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * Saves a token for this gateway. |
|
| 229 | - * |
|
| 230 | - * @since 1.0.19 |
|
| 231 | - */ |
|
| 232 | - public function save_token( $token ) { |
|
| 233 | - |
|
| 234 | - $tokens = $this->get_tokens(); |
|
| 235 | - $tokens[] = $token; |
|
| 236 | - |
|
| 237 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
| 238 | - |
|
| 239 | - $this->tokens = $tokens; |
|
| 240 | - |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Return the title for admin screens. |
|
| 245 | - * |
|
| 246 | - * @return string |
|
| 247 | - */ |
|
| 248 | - public function get_method_title() { |
|
| 249 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Return the description for admin screens. |
|
| 254 | - * |
|
| 255 | - * @return string |
|
| 256 | - */ |
|
| 257 | - public function get_method_description() { |
|
| 258 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Get the success url. |
|
| 263 | - * |
|
| 264 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 265 | - * @return string |
|
| 266 | - */ |
|
| 267 | - public function get_return_url( $invoice ) { |
|
| 268 | - |
|
| 269 | - // Payment success url |
|
| 270 | - $return_url = add_query_arg( |
|
| 271 | - array( |
|
| 272 | - 'payment-confirm' => $this->id, |
|
| 273 | - 'invoice_key' => $invoice->get_key(), |
|
| 274 | - 'utm_nooverride' => 1 |
|
| 275 | - ), |
|
| 276 | - wpinv_get_success_page_uri() |
|
| 277 | - ); |
|
| 278 | - |
|
| 279 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * Confirms payments when rendering the success page. |
|
| 284 | - * |
|
| 285 | - * @param string $content Success page content. |
|
| 286 | - * @return string |
|
| 287 | - */ |
|
| 288 | - public function confirm_payment( $content ) { |
|
| 289 | - |
|
| 290 | - // Retrieve the invoice. |
|
| 291 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
| 292 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 293 | - |
|
| 294 | - // Ensure that it exists and that it is pending payment. |
|
| 295 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 296 | - return $content; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - // Can the user view this invoice?? |
|
| 300 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 301 | - return $content; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // Show payment processing indicator. |
|
| 305 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * Processes ipns and marks payments as complete. |
|
| 310 | - * |
|
| 311 | - * @return void |
|
| 312 | - */ |
|
| 313 | - public function verify_ipn() {} |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * Processes invoice addons. |
|
| 317 | - * |
|
| 318 | - * @param WPInv_Invoice $invoice |
|
| 319 | - * @param GetPaid_Form_Item[] $items |
|
| 320 | - * @return WPInv_Invoice |
|
| 321 | - */ |
|
| 322 | - public function process_addons( $invoice, $items ) { |
|
| 323 | - |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
| 328 | - * |
|
| 329 | - * @param string $transaction_url transaction url. |
|
| 330 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 331 | - * @return string transaction URL, or empty string. |
|
| 332 | - */ |
|
| 333 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 334 | - |
|
| 335 | - $transaction_id = $invoice->get_transaction_id(); |
|
| 336 | - |
|
| 337 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 338 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 339 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 340 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return $transaction_url; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
| 348 | - * |
|
| 349 | - * @param string $subscription_url transaction url. |
|
| 350 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
| 351 | - * @return string subscription URL, or empty string. |
|
| 352 | - */ |
|
| 353 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
| 354 | - |
|
| 355 | - $profile_id = $subscription->get_profile_id(); |
|
| 356 | - |
|
| 357 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 358 | - |
|
| 359 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 360 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
| 361 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 362 | - |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - return $subscription_url; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * Check if the gateway is available for use. |
|
| 370 | - * |
|
| 371 | - * @return bool |
|
| 372 | - */ |
|
| 373 | - public function is_available() { |
|
| 374 | - return ! empty( $this->enabled ); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * Return the gateway's title. |
|
| 379 | - * |
|
| 380 | - * @return string |
|
| 381 | - */ |
|
| 382 | - public function get_title() { |
|
| 383 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * Return the gateway's description. |
|
| 388 | - * |
|
| 389 | - * @return string |
|
| 390 | - */ |
|
| 391 | - public function get_description() { |
|
| 392 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Process Payment. |
|
| 397 | - * |
|
| 398 | - * |
|
| 399 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 400 | - * @param array $submission_data Posted checkout fields. |
|
| 401 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 402 | - * @return void |
|
| 403 | - */ |
|
| 404 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 405 | - // Process the payment then either redirect to the success page or the gateway. |
|
| 406 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * Process refund. |
|
| 411 | - * |
|
| 412 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
| 413 | - * a passed in amount. |
|
| 414 | - * |
|
| 415 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 416 | - * @param float $amount Refund amount. |
|
| 417 | - * @param string $reason Refund reason. |
|
| 418 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
| 419 | - */ |
|
| 420 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 421 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * Displays the payment fields, credit cards etc. |
|
| 426 | - * |
|
| 427 | - * @param int $invoice_id 0 or invoice id. |
|
| 428 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
| 429 | - */ |
|
| 430 | - public function payment_fields( $invoice_id, $form ) { |
|
| 431 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * Filters the gateway settings. |
|
| 436 | - * |
|
| 437 | - * @param array $admin_settings |
|
| 438 | - */ |
|
| 439 | - public function admin_settings( $admin_settings ) { |
|
| 440 | - return $admin_settings; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * Retrieves the value of a gateway setting. |
|
| 445 | - * |
|
| 446 | - * @param string $option |
|
| 447 | - */ |
|
| 448 | - public function get_option( $option, $default = false ) { |
|
| 449 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * Check if a gateway supports a given feature. |
|
| 454 | - * |
|
| 455 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
| 456 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
| 457 | - * |
|
| 458 | - * @param string $feature string The name of a feature to test support for. |
|
| 459 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
| 460 | - * @since 1.0.19 |
|
| 461 | - */ |
|
| 462 | - public function supports( $feature ) { |
|
| 463 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * Returns the credit card form html. |
|
| 468 | - * |
|
| 469 | - * @param bool $save whether or not to display the save button. |
|
| 470 | - */ |
|
| 162 | + // Gateway checkout fiellds. |
|
| 163 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 164 | + |
|
| 165 | + // Process payment. |
|
| 166 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 167 | + |
|
| 168 | + // Change the checkout button text. |
|
| 169 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
| 170 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + // Check if a gateway is valid for a given currency. |
|
| 174 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 175 | + |
|
| 176 | + // Generate the transaction url. |
|
| 177 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 178 | + |
|
| 179 | + // Generate the subscription url. |
|
| 180 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
| 181 | + |
|
| 182 | + // Confirm payments. |
|
| 183 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 184 | + |
|
| 185 | + // Verify IPNs. |
|
| 186 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 187 | + |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Checks if this gateway is a given gateway. |
|
| 192 | + * |
|
| 193 | + * @since 1.0.19 |
|
| 194 | + * @return bool |
|
| 195 | + */ |
|
| 196 | + public function is( $gateway ) { |
|
| 197 | + return $gateway == $this->id; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Returns a users saved tokens for this gateway. |
|
| 202 | + * |
|
| 203 | + * @since 1.0.19 |
|
| 204 | + * @return array |
|
| 205 | + */ |
|
| 206 | + public function get_tokens( $sandbox = null ) { |
|
| 207 | + |
|
| 208 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
| 209 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 210 | + |
|
| 211 | + if ( is_array( $tokens ) ) { |
|
| 212 | + $this->tokens = $tokens; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + if ( ! is_bool( $sandbox ) ) { |
|
| 218 | + return $this->tokens; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // Filter tokens. |
|
| 222 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
| 223 | + return wp_list_filter( $this->tokens, $args ); |
|
| 224 | + |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * Saves a token for this gateway. |
|
| 229 | + * |
|
| 230 | + * @since 1.0.19 |
|
| 231 | + */ |
|
| 232 | + public function save_token( $token ) { |
|
| 233 | + |
|
| 234 | + $tokens = $this->get_tokens(); |
|
| 235 | + $tokens[] = $token; |
|
| 236 | + |
|
| 237 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
| 238 | + |
|
| 239 | + $this->tokens = $tokens; |
|
| 240 | + |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Return the title for admin screens. |
|
| 245 | + * |
|
| 246 | + * @return string |
|
| 247 | + */ |
|
| 248 | + public function get_method_title() { |
|
| 249 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Return the description for admin screens. |
|
| 254 | + * |
|
| 255 | + * @return string |
|
| 256 | + */ |
|
| 257 | + public function get_method_description() { |
|
| 258 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Get the success url. |
|
| 263 | + * |
|
| 264 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 265 | + * @return string |
|
| 266 | + */ |
|
| 267 | + public function get_return_url( $invoice ) { |
|
| 268 | + |
|
| 269 | + // Payment success url |
|
| 270 | + $return_url = add_query_arg( |
|
| 271 | + array( |
|
| 272 | + 'payment-confirm' => $this->id, |
|
| 273 | + 'invoice_key' => $invoice->get_key(), |
|
| 274 | + 'utm_nooverride' => 1 |
|
| 275 | + ), |
|
| 276 | + wpinv_get_success_page_uri() |
|
| 277 | + ); |
|
| 278 | + |
|
| 279 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Confirms payments when rendering the success page. |
|
| 284 | + * |
|
| 285 | + * @param string $content Success page content. |
|
| 286 | + * @return string |
|
| 287 | + */ |
|
| 288 | + public function confirm_payment( $content ) { |
|
| 289 | + |
|
| 290 | + // Retrieve the invoice. |
|
| 291 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
| 292 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 293 | + |
|
| 294 | + // Ensure that it exists and that it is pending payment. |
|
| 295 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 296 | + return $content; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + // Can the user view this invoice?? |
|
| 300 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 301 | + return $content; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // Show payment processing indicator. |
|
| 305 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * Processes ipns and marks payments as complete. |
|
| 310 | + * |
|
| 311 | + * @return void |
|
| 312 | + */ |
|
| 313 | + public function verify_ipn() {} |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Processes invoice addons. |
|
| 317 | + * |
|
| 318 | + * @param WPInv_Invoice $invoice |
|
| 319 | + * @param GetPaid_Form_Item[] $items |
|
| 320 | + * @return WPInv_Invoice |
|
| 321 | + */ |
|
| 322 | + public function process_addons( $invoice, $items ) { |
|
| 323 | + |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
| 328 | + * |
|
| 329 | + * @param string $transaction_url transaction url. |
|
| 330 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 331 | + * @return string transaction URL, or empty string. |
|
| 332 | + */ |
|
| 333 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 334 | + |
|
| 335 | + $transaction_id = $invoice->get_transaction_id(); |
|
| 336 | + |
|
| 337 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 338 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 339 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 340 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return $transaction_url; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
| 348 | + * |
|
| 349 | + * @param string $subscription_url transaction url. |
|
| 350 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
| 351 | + * @return string subscription URL, or empty string. |
|
| 352 | + */ |
|
| 353 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
| 354 | + |
|
| 355 | + $profile_id = $subscription->get_profile_id(); |
|
| 356 | + |
|
| 357 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 358 | + |
|
| 359 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 360 | + $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
| 361 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 362 | + |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + return $subscription_url; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * Check if the gateway is available for use. |
|
| 370 | + * |
|
| 371 | + * @return bool |
|
| 372 | + */ |
|
| 373 | + public function is_available() { |
|
| 374 | + return ! empty( $this->enabled ); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * Return the gateway's title. |
|
| 379 | + * |
|
| 380 | + * @return string |
|
| 381 | + */ |
|
| 382 | + public function get_title() { |
|
| 383 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * Return the gateway's description. |
|
| 388 | + * |
|
| 389 | + * @return string |
|
| 390 | + */ |
|
| 391 | + public function get_description() { |
|
| 392 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Process Payment. |
|
| 397 | + * |
|
| 398 | + * |
|
| 399 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 400 | + * @param array $submission_data Posted checkout fields. |
|
| 401 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 402 | + * @return void |
|
| 403 | + */ |
|
| 404 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 405 | + // Process the payment then either redirect to the success page or the gateway. |
|
| 406 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * Process refund. |
|
| 411 | + * |
|
| 412 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
| 413 | + * a passed in amount. |
|
| 414 | + * |
|
| 415 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 416 | + * @param float $amount Refund amount. |
|
| 417 | + * @param string $reason Refund reason. |
|
| 418 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
| 419 | + */ |
|
| 420 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 421 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * Displays the payment fields, credit cards etc. |
|
| 426 | + * |
|
| 427 | + * @param int $invoice_id 0 or invoice id. |
|
| 428 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
| 429 | + */ |
|
| 430 | + public function payment_fields( $invoice_id, $form ) { |
|
| 431 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * Filters the gateway settings. |
|
| 436 | + * |
|
| 437 | + * @param array $admin_settings |
|
| 438 | + */ |
|
| 439 | + public function admin_settings( $admin_settings ) { |
|
| 440 | + return $admin_settings; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * Retrieves the value of a gateway setting. |
|
| 445 | + * |
|
| 446 | + * @param string $option |
|
| 447 | + */ |
|
| 448 | + public function get_option( $option, $default = false ) { |
|
| 449 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * Check if a gateway supports a given feature. |
|
| 454 | + * |
|
| 455 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
| 456 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
| 457 | + * |
|
| 458 | + * @param string $feature string The name of a feature to test support for. |
|
| 459 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
| 460 | + * @since 1.0.19 |
|
| 461 | + */ |
|
| 462 | + public function supports( $feature ) { |
|
| 463 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * Returns the credit card form html. |
|
| 468 | + * |
|
| 469 | + * @param bool $save whether or not to display the save button. |
|
| 470 | + */ |
|
| 471 | 471 | public function get_cc_form( $save = false ) { |
| 472 | 472 | |
| 473 | - ob_start(); |
|
| 473 | + ob_start(); |
|
| 474 | 474 | |
| 475 | 475 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
| 476 | 476 | |
@@ -565,11 +565,11 @@ discard block |
||
| 565 | 565 | 'name' => $this->id . '[cc_cvv2]', |
| 566 | 566 | 'id' => "$id_prefix-cc-cvv2", |
| 567 | 567 | 'label' => __( 'CCV', 'invoicing' ), |
| 568 | - 'label_type' => 'vertical', |
|
| 569 | - 'class' => 'form-control-sm', |
|
| 570 | - 'extra_attributes' => array( |
|
| 571 | - 'autocomplete' => "cc-csc", |
|
| 572 | - ), |
|
| 568 | + 'label_type' => 'vertical', |
|
| 569 | + 'class' => 'form-control-sm', |
|
| 570 | + 'extra_attributes' => array( |
|
| 571 | + 'autocomplete' => "cc-csc", |
|
| 572 | + ), |
|
| 573 | 573 | ) |
| 574 | 574 | ); |
| 575 | 575 | ?> |
@@ -579,192 +579,192 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | <?php |
| 581 | 581 | |
| 582 | - if ( $save ) { |
|
| 583 | - echo $this->save_payment_method_checkbox(); |
|
| 584 | - } |
|
| 582 | + if ( $save ) { |
|
| 583 | + echo $this->save_payment_method_checkbox(); |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | - ?> |
|
| 586 | + ?> |
|
| 587 | 587 | </div> |
| 588 | 588 | |
| 589 | 589 | </div> |
| 590 | 590 | <?php |
| 591 | 591 | |
| 592 | - return ob_get_clean(); |
|
| 592 | + return ob_get_clean(); |
|
| 593 | + |
|
| 594 | + } |
|
| 593 | 595 | |
| 596 | + /** |
|
| 597 | + * Displays a new payment method entry form. |
|
| 598 | + * |
|
| 599 | + * @since 1.0.19 |
|
| 600 | + */ |
|
| 601 | + public function new_payment_method_entry( $form ) { |
|
| 602 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
| 594 | 603 | } |
| 595 | 604 | |
| 596 | - /** |
|
| 597 | - * Displays a new payment method entry form. |
|
| 598 | - * |
|
| 599 | - * @since 1.0.19 |
|
| 600 | - */ |
|
| 601 | - public function new_payment_method_entry( $form ) { |
|
| 602 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
| 603 | - } |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * Grab and display our saved payment methods. |
|
| 607 | - * |
|
| 608 | - * @since 1.0.19 |
|
| 609 | - */ |
|
| 610 | - public function saved_payment_methods() { |
|
| 611 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
| 612 | - |
|
| 613 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
| 614 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - $html .= $this->get_new_payment_method_option_html(); |
|
| 618 | - $html .= '</ul>'; |
|
| 619 | - |
|
| 620 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - /** |
|
| 624 | - * Gets saved payment method HTML from a token. |
|
| 625 | - * |
|
| 626 | - * @since 1.0.19 |
|
| 627 | - * @param array $token Payment Token. |
|
| 628 | - * @return string Generated payment method HTML |
|
| 629 | - */ |
|
| 630 | - public function get_saved_payment_method_option_html( $token ) { |
|
| 631 | - |
|
| 632 | - return sprintf( |
|
| 633 | - '<li class="getpaid-payment-method form-group"> |
|
| 605 | + /** |
|
| 606 | + * Grab and display our saved payment methods. |
|
| 607 | + * |
|
| 608 | + * @since 1.0.19 |
|
| 609 | + */ |
|
| 610 | + public function saved_payment_methods() { |
|
| 611 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
| 612 | + |
|
| 613 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
| 614 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + $html .= $this->get_new_payment_method_option_html(); |
|
| 618 | + $html .= '</ul>'; |
|
| 619 | + |
|
| 620 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + /** |
|
| 624 | + * Gets saved payment method HTML from a token. |
|
| 625 | + * |
|
| 626 | + * @since 1.0.19 |
|
| 627 | + * @param array $token Payment Token. |
|
| 628 | + * @return string Generated payment method HTML |
|
| 629 | + */ |
|
| 630 | + public function get_saved_payment_method_option_html( $token ) { |
|
| 631 | + |
|
| 632 | + return sprintf( |
|
| 633 | + '<li class="getpaid-payment-method form-group"> |
|
| 634 | 634 | <label> |
| 635 | 635 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
| 636 | 636 | <span>%3$s</span> |
| 637 | 637 | </label> |
| 638 | 638 | </li>', |
| 639 | - esc_attr( $this->id ), |
|
| 640 | - esc_attr( $token['id'] ), |
|
| 641 | - esc_html( $token['name'] ), |
|
| 642 | - checked( empty( $token['default'] ), false, false ), |
|
| 643 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
| 644 | - ); |
|
| 645 | - |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - /** |
|
| 649 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
| 650 | - * |
|
| 651 | - * @since 1.0.19 |
|
| 652 | - */ |
|
| 653 | - public function get_new_payment_method_option_html() { |
|
| 654 | - |
|
| 655 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 656 | - |
|
| 657 | - return sprintf( |
|
| 658 | - '<li class="getpaid-new-payment-method"> |
|
| 639 | + esc_attr( $this->id ), |
|
| 640 | + esc_attr( $token['id'] ), |
|
| 641 | + esc_html( $token['name'] ), |
|
| 642 | + checked( empty( $token['default'] ), false, false ), |
|
| 643 | + empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
| 644 | + ); |
|
| 645 | + |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + /** |
|
| 649 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
| 650 | + * |
|
| 651 | + * @since 1.0.19 |
|
| 652 | + */ |
|
| 653 | + public function get_new_payment_method_option_html() { |
|
| 654 | + |
|
| 655 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 656 | + |
|
| 657 | + return sprintf( |
|
| 658 | + '<li class="getpaid-new-payment-method"> |
|
| 659 | 659 | <label> |
| 660 | 660 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
| 661 | 661 | <span>%2$s</span> |
| 662 | 662 | </label> |
| 663 | 663 | </li>', |
| 664 | - esc_attr( $this->id ), |
|
| 665 | - esc_html( $label ) |
|
| 666 | - ); |
|
| 667 | - |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - /** |
|
| 671 | - * Outputs a checkbox for saving a new payment method to the database. |
|
| 672 | - * |
|
| 673 | - * @since 1.0.19 |
|
| 674 | - */ |
|
| 675 | - public function save_payment_method_checkbox() { |
|
| 676 | - |
|
| 677 | - return aui()->input( |
|
| 678 | - array( |
|
| 679 | - 'type' => 'checkbox', |
|
| 680 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
| 681 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
| 682 | - 'required' => false, |
|
| 683 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
| 684 | - 'value' => 'true', |
|
| 685 | - 'checked' => true, |
|
| 686 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
| 687 | - ) |
|
| 688 | - ); |
|
| 689 | - |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - /** |
|
| 693 | - * Registers the gateway. |
|
| 694 | - * |
|
| 695 | - * @return array |
|
| 696 | - */ |
|
| 697 | - public function register_gateway( $gateways ) { |
|
| 698 | - |
|
| 699 | - $gateways[ $this->id ] = array( |
|
| 700 | - |
|
| 701 | - 'admin_label' => $this->method_title, |
|
| 664 | + esc_attr( $this->id ), |
|
| 665 | + esc_html( $label ) |
|
| 666 | + ); |
|
| 667 | + |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + /** |
|
| 671 | + * Outputs a checkbox for saving a new payment method to the database. |
|
| 672 | + * |
|
| 673 | + * @since 1.0.19 |
|
| 674 | + */ |
|
| 675 | + public function save_payment_method_checkbox() { |
|
| 676 | + |
|
| 677 | + return aui()->input( |
|
| 678 | + array( |
|
| 679 | + 'type' => 'checkbox', |
|
| 680 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
| 681 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
| 682 | + 'required' => false, |
|
| 683 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
| 684 | + 'value' => 'true', |
|
| 685 | + 'checked' => true, |
|
| 686 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
| 687 | + ) |
|
| 688 | + ); |
|
| 689 | + |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + /** |
|
| 693 | + * Registers the gateway. |
|
| 694 | + * |
|
| 695 | + * @return array |
|
| 696 | + */ |
|
| 697 | + public function register_gateway( $gateways ) { |
|
| 698 | + |
|
| 699 | + $gateways[ $this->id ] = array( |
|
| 700 | + |
|
| 701 | + 'admin_label' => $this->method_title, |
|
| 702 | 702 | 'checkout_label' => $this->title, |
| 703 | - 'ordering' => $this->order, |
|
| 703 | + 'ordering' => $this->order, |
|
| 704 | 704 | |
| 705 | - ); |
|
| 705 | + ); |
|
| 706 | 706 | |
| 707 | - return $gateways; |
|
| 707 | + return $gateways; |
|
| 708 | 708 | |
| 709 | - } |
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | - /** |
|
| 712 | - * Checks whether or not this is a sandbox request. |
|
| 713 | - * |
|
| 714 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
| 715 | - * @return bool |
|
| 716 | - */ |
|
| 717 | - public function is_sandbox( $invoice = null ) { |
|
| 711 | + /** |
|
| 712 | + * Checks whether or not this is a sandbox request. |
|
| 713 | + * |
|
| 714 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
| 715 | + * @return bool |
|
| 716 | + */ |
|
| 717 | + public function is_sandbox( $invoice = null ) { |
|
| 718 | 718 | |
| 719 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 720 | - return $invoice->get_mode() == 'test'; |
|
| 721 | - } |
|
| 719 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 720 | + return $invoice->get_mode() == 'test'; |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | - return wpinv_is_test_mode( $this->id ); |
|
| 723 | + return wpinv_is_test_mode( $this->id ); |
|
| 724 | 724 | |
| 725 | - } |
|
| 725 | + } |
|
| 726 | 726 | |
| 727 | - /** |
|
| 728 | - * Renames the checkout button |
|
| 729 | - * |
|
| 730 | - * @return string |
|
| 731 | - */ |
|
| 732 | - public function rename_checkout_button() { |
|
| 733 | - return $this->checkout_button_text; |
|
| 734 | - } |
|
| 727 | + /** |
|
| 728 | + * Renames the checkout button |
|
| 729 | + * |
|
| 730 | + * @return string |
|
| 731 | + */ |
|
| 732 | + public function rename_checkout_button() { |
|
| 733 | + return $this->checkout_button_text; |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | - /** |
|
| 737 | - * Validate gateway currency |
|
| 738 | - * |
|
| 739 | - * @return bool |
|
| 740 | - */ |
|
| 741 | - public function validate_currency( $validation, $currency ) { |
|
| 736 | + /** |
|
| 737 | + * Validate gateway currency |
|
| 738 | + * |
|
| 739 | + * @return bool |
|
| 740 | + */ |
|
| 741 | + public function validate_currency( $validation, $currency ) { |
|
| 742 | 742 | |
| 743 | - // Required currencies. |
|
| 744 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 745 | - return false; |
|
| 746 | - } |
|
| 743 | + // Required currencies. |
|
| 744 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 745 | + return false; |
|
| 746 | + } |
|
| 747 | 747 | |
| 748 | - // Excluded currencies. |
|
| 749 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 750 | - return false; |
|
| 751 | - } |
|
| 748 | + // Excluded currencies. |
|
| 749 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 750 | + return false; |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - return $validation; |
|
| 754 | - } |
|
| 753 | + return $validation; |
|
| 754 | + } |
|
| 755 | 755 | |
| 756 | - /** |
|
| 757 | - * Displays an error |
|
| 758 | - * |
|
| 759 | - */ |
|
| 760 | - public function show_error( $code, $message, $type ) { |
|
| 756 | + /** |
|
| 757 | + * Displays an error |
|
| 758 | + * |
|
| 759 | + */ |
|
| 760 | + public function show_error( $code, $message, $type ) { |
|
| 761 | 761 | |
| 762 | - if ( is_admin() ) { |
|
| 763 | - getpaid_admin()->{"show_$type"}( $message ); |
|
| 764 | - } |
|
| 762 | + if ( is_admin() ) { |
|
| 763 | + getpaid_admin()->{"show_$type"}( $message ); |
|
| 764 | + } |
|
| 765 | 765 | |
| 766 | - wpinv_set_error( $code, $message, $type ); |
|
| 766 | + wpinv_set_error( $code, $message, $type ); |
|
| 767 | 767 | |
| 768 | - } |
|
| 768 | + } |
|
| 769 | 769 | |
| 770 | 770 | } |
@@ -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 | * Abstaract Payment Gateway class. |
@@ -139,51 +139,51 @@ discard block |
||
| 139 | 139 | public function __construct() { |
| 140 | 140 | |
| 141 | 141 | // Register gateway. |
| 142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
| 143 | 143 | |
| 144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
| 145 | 145 | |
| 146 | 146 | // Add support for various features. |
| 147 | - foreach ( $this->supports as $feature ) { |
|
| 148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
| 149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
| 150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
| 147 | + foreach ($this->supports as $feature) { |
|
| 148 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
| 149 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
| 150 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Invoice addons. |
| 154 | - if ( $this->supports( 'addons' ) ) { |
|
| 155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
| 154 | + if ($this->supports('addons')) { |
|
| 155 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Gateway settings. |
| 159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
| 159 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
| 160 | 160 | |
| 161 | 161 | |
| 162 | 162 | // Gateway checkout fiellds. |
| 163 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 163 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
| 164 | 164 | |
| 165 | 165 | // Process payment. |
| 166 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 166 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
| 167 | 167 | |
| 168 | 168 | // Change the checkout button text. |
| 169 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
| 170 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 169 | + if (!empty($this->checkout_button_text)) { |
|
| 170 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Check if a gateway is valid for a given currency. |
| 174 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 174 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
| 175 | 175 | |
| 176 | 176 | // Generate the transaction url. |
| 177 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 177 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
| 178 | 178 | |
| 179 | 179 | // Generate the subscription url. |
| 180 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
| 180 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
| 181 | 181 | |
| 182 | 182 | // Confirm payments. |
| 183 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 183 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
| 184 | 184 | |
| 185 | 185 | // Verify IPNs. |
| 186 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 186 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @since 1.0.19 |
| 194 | 194 | * @return bool |
| 195 | 195 | */ |
| 196 | - public function is( $gateway ) { |
|
| 196 | + public function is($gateway) { |
|
| 197 | 197 | return $gateway == $this->id; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -203,24 +203,24 @@ discard block |
||
| 203 | 203 | * @since 1.0.19 |
| 204 | 204 | * @return array |
| 205 | 205 | */ |
| 206 | - public function get_tokens( $sandbox = null ) { |
|
| 206 | + public function get_tokens($sandbox = null) { |
|
| 207 | 207 | |
| 208 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
| 209 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 208 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
| 209 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
| 210 | 210 | |
| 211 | - if ( is_array( $tokens ) ) { |
|
| 211 | + if (is_array($tokens)) { |
|
| 212 | 212 | $this->tokens = $tokens; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if ( ! is_bool( $sandbox ) ) { |
|
| 217 | + if (!is_bool($sandbox)) { |
|
| 218 | 218 | return $this->tokens; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // Filter tokens. |
| 222 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
| 223 | - return wp_list_filter( $this->tokens, $args ); |
|
| 222 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
| 223 | + return wp_list_filter($this->tokens, $args); |
|
| 224 | 224 | |
| 225 | 225 | } |
| 226 | 226 | |
@@ -229,12 +229,12 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @since 1.0.19 |
| 231 | 231 | */ |
| 232 | - public function save_token( $token ) { |
|
| 232 | + public function save_token($token) { |
|
| 233 | 233 | |
| 234 | 234 | $tokens = $this->get_tokens(); |
| 235 | 235 | $tokens[] = $token; |
| 236 | 236 | |
| 237 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
| 237 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
| 238 | 238 | |
| 239 | 239 | $this->tokens = $tokens; |
| 240 | 240 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @return string |
| 247 | 247 | */ |
| 248 | 248 | public function get_method_title() { |
| 249 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 249 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @return string |
| 256 | 256 | */ |
| 257 | 257 | public function get_method_description() { |
| 258 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 258 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * @param WPInv_Invoice $invoice Invoice object. |
| 265 | 265 | * @return string |
| 266 | 266 | */ |
| 267 | - public function get_return_url( $invoice ) { |
|
| 267 | + public function get_return_url($invoice) { |
|
| 268 | 268 | |
| 269 | 269 | // Payment success url |
| 270 | 270 | $return_url = add_query_arg( |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | wpinv_get_success_page_uri() |
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 279 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -285,24 +285,24 @@ discard block |
||
| 285 | 285 | * @param string $content Success page content. |
| 286 | 286 | * @return string |
| 287 | 287 | */ |
| 288 | - public function confirm_payment( $content ) { |
|
| 288 | + public function confirm_payment($content) { |
|
| 289 | 289 | |
| 290 | 290 | // Retrieve the invoice. |
| 291 | 291 | $invoice_id = getpaid_get_current_invoice_id(); |
| 292 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 292 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 293 | 293 | |
| 294 | 294 | // Ensure that it exists and that it is pending payment. |
| 295 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 295 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
| 296 | 296 | return $content; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Can the user view this invoice?? |
| 300 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 300 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
| 301 | 301 | return $content; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Show payment processing indicator. |
| 305 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 305 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @param GetPaid_Form_Item[] $items |
| 320 | 320 | * @return WPInv_Invoice |
| 321 | 321 | */ |
| 322 | - public function process_addons( $invoice, $items ) { |
|
| 322 | + public function process_addons($invoice, $items) { |
|
| 323 | 323 | |
| 324 | 324 | } |
| 325 | 325 | |
@@ -330,14 +330,14 @@ discard block |
||
| 330 | 330 | * @param WPInv_Invoice $invoice Invoice object. |
| 331 | 331 | * @return string transaction URL, or empty string. |
| 332 | 332 | */ |
| 333 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 333 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
| 334 | 334 | |
| 335 | - $transaction_id = $invoice->get_transaction_id(); |
|
| 335 | + $transaction_id = $invoice->get_transaction_id(); |
|
| 336 | 336 | |
| 337 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 338 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 339 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 340 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 337 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
| 338 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
| 339 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
| 340 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | return $transaction_url; |
@@ -350,15 +350,15 @@ discard block |
||
| 350 | 350 | * @param WPInv_Subscription $subscription Subscription objectt. |
| 351 | 351 | * @return string subscription URL, or empty string. |
| 352 | 352 | */ |
| 353 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
| 353 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
| 354 | 354 | |
| 355 | - $profile_id = $subscription->get_profile_id(); |
|
| 355 | + $profile_id = $subscription->get_profile_id(); |
|
| 356 | 356 | |
| 357 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 357 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
| 358 | 358 | |
| 359 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 360 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
| 361 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 359 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
| 360 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
| 361 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @return bool |
| 372 | 372 | */ |
| 373 | 373 | public function is_available() { |
| 374 | - return ! empty( $this->enabled ); |
|
| 374 | + return !empty($this->enabled); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @return string |
| 381 | 381 | */ |
| 382 | 382 | public function get_title() { |
| 383 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 383 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @return string |
| 390 | 390 | */ |
| 391 | 391 | public function get_description() { |
| 392 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 392 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -401,9 +401,9 @@ discard block |
||
| 401 | 401 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 402 | 402 | * @return void |
| 403 | 403 | */ |
| 404 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 404 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 405 | 405 | // Process the payment then either redirect to the success page or the gateway. |
| 406 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
| 406 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | * @param string $reason Refund reason. |
| 418 | 418 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
| 419 | 419 | */ |
| 420 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 421 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
| 420 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
| 421 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -427,8 +427,8 @@ discard block |
||
| 427 | 427 | * @param int $invoice_id 0 or invoice id. |
| 428 | 428 | * @param GetPaid_Payment_Form $form Current payment form. |
| 429 | 429 | */ |
| 430 | - public function payment_fields( $invoice_id, $form ) { |
|
| 431 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
| 430 | + public function payment_fields($invoice_id, $form) { |
|
| 431 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | * |
| 437 | 437 | * @param array $admin_settings |
| 438 | 438 | */ |
| 439 | - public function admin_settings( $admin_settings ) { |
|
| 439 | + public function admin_settings($admin_settings) { |
|
| 440 | 440 | return $admin_settings; |
| 441 | 441 | } |
| 442 | 442 | |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | * |
| 446 | 446 | * @param string $option |
| 447 | 447 | */ |
| 448 | - public function get_option( $option, $default = false ) { |
|
| 449 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
| 448 | + public function get_option($option, $default = false) { |
|
| 449 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -459,8 +459,8 @@ discard block |
||
| 459 | 459 | * @return bool True if the gateway supports the feature, false otherwise. |
| 460 | 460 | * @since 1.0.19 |
| 461 | 461 | */ |
| 462 | - public function supports( $feature ) { |
|
| 463 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
| 462 | + public function supports($feature) { |
|
| 463 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | /** |
@@ -468,36 +468,36 @@ discard block |
||
| 468 | 468 | * |
| 469 | 469 | * @param bool $save whether or not to display the save button. |
| 470 | 470 | */ |
| 471 | - public function get_cc_form( $save = false ) { |
|
| 471 | + public function get_cc_form($save = false) { |
|
| 472 | 472 | |
| 473 | 473 | ob_start(); |
| 474 | 474 | |
| 475 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
| 475 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
| 476 | 476 | |
| 477 | 477 | $months = array( |
| 478 | - '01' => __( 'January', 'invoicing' ), |
|
| 479 | - '02' => __( 'February', 'invoicing' ), |
|
| 480 | - '03' => __( 'March', 'invoicing' ), |
|
| 481 | - '04' => __( 'April', 'invoicing' ), |
|
| 482 | - '05' => __( 'May', 'invoicing' ), |
|
| 483 | - '06' => __( 'June', 'invoicing' ), |
|
| 484 | - '07' => __( 'July', 'invoicing' ), |
|
| 485 | - '08' => __( 'August', 'invoicing' ), |
|
| 486 | - '09' => __( 'September', 'invoicing' ), |
|
| 487 | - '10' => __( 'October', 'invoicing' ), |
|
| 488 | - '11' => __( 'November', 'invoicing' ), |
|
| 489 | - '12' => __( 'December', 'invoicing' ), |
|
| 478 | + '01' => __('January', 'invoicing'), |
|
| 479 | + '02' => __('February', 'invoicing'), |
|
| 480 | + '03' => __('March', 'invoicing'), |
|
| 481 | + '04' => __('April', 'invoicing'), |
|
| 482 | + '05' => __('May', 'invoicing'), |
|
| 483 | + '06' => __('June', 'invoicing'), |
|
| 484 | + '07' => __('July', 'invoicing'), |
|
| 485 | + '08' => __('August', 'invoicing'), |
|
| 486 | + '09' => __('September', 'invoicing'), |
|
| 487 | + '10' => __('October', 'invoicing'), |
|
| 488 | + '11' => __('November', 'invoicing'), |
|
| 489 | + '12' => __('December', 'invoicing'), |
|
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
| 492 | + $year = (int) date('Y', current_time('timestamp')); |
|
| 493 | 493 | $years = array(); |
| 494 | 494 | |
| 495 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
| 496 | - $years[ $year + $i ] = $year + $i; |
|
| 495 | + for ($i = 0; $i <= 10; $i++) { |
|
| 496 | + $years[$year + $i] = $year + $i; |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | ?> |
| 500 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1"> |
|
| 500 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
| 501 | 501 | |
| 502 | 502 | |
| 503 | 503 | <div class="getpaid-cc-card-inner"> |
@@ -506,14 +506,14 @@ discard block |
||
| 506 | 506 | <div class="col-12"> |
| 507 | 507 | |
| 508 | 508 | <div class="form-group"> |
| 509 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label> |
|
| 509 | + <label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label> |
|
| 510 | 510 | <div class="input-group input-group-sm"> |
| 511 | 511 | <div class="input-group-prepend "> |
| 512 | 512 | <span class="input-group-text"> |
| 513 | 513 | <i class="fa fa-credit-card"></i> |
| 514 | 514 | </span> |
| 515 | 515 | </div> |
| 516 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
| 516 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
| 517 | 517 | </div> |
| 518 | 518 | </div> |
| 519 | 519 | |
@@ -521,17 +521,17 @@ discard block |
||
| 521 | 521 | |
| 522 | 522 | <div class="col-12"> |
| 523 | 523 | <div class="form-group"> |
| 524 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
| 524 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
| 525 | 525 | <div class="form-row"> |
| 526 | 526 | |
| 527 | 527 | <div class="col"> |
| 528 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
| 529 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
| 528 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
| 529 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
| 530 | 530 | |
| 531 | 531 | <?php |
| 532 | - foreach ( $months as $key => $month ) { |
|
| 533 | - $key = esc_attr( $key ); |
|
| 534 | - $month = wpinv_clean( $month ); |
|
| 532 | + foreach ($months as $key => $month) { |
|
| 533 | + $key = esc_attr($key); |
|
| 534 | + $month = wpinv_clean($month); |
|
| 535 | 535 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
| 536 | 536 | } |
| 537 | 537 | ?> |
@@ -540,13 +540,13 @@ discard block |
||
| 540 | 540 | </div> |
| 541 | 541 | |
| 542 | 542 | <div class="col"> |
| 543 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
| 544 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
| 543 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
| 544 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
| 545 | 545 | |
| 546 | 546 | <?php |
| 547 | - foreach ( $years as $key => $year ) { |
|
| 548 | - $key = esc_attr( $key ); |
|
| 549 | - $year = wpinv_clean( $year ); |
|
| 547 | + foreach ($years as $key => $year) { |
|
| 548 | + $key = esc_attr($key); |
|
| 549 | + $year = wpinv_clean($year); |
|
| 550 | 550 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
| 551 | 551 | } |
| 552 | 552 | ?> |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | array( |
| 565 | 565 | 'name' => $this->id . '[cc_cvv2]', |
| 566 | 566 | 'id' => "$id_prefix-cc-cvv2", |
| 567 | - 'label' => __( 'CCV', 'invoicing' ), |
|
| 567 | + 'label' => __('CCV', 'invoicing'), |
|
| 568 | 568 | 'label_type' => 'vertical', |
| 569 | 569 | 'class' => 'form-control-sm', |
| 570 | 570 | 'extra_attributes' => array( |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | <?php |
| 581 | 581 | |
| 582 | - if ( $save ) { |
|
| 582 | + if ($save) { |
|
| 583 | 583 | echo $this->save_payment_method_checkbox(); |
| 584 | 584 | } |
| 585 | 585 | |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | * |
| 599 | 599 | * @since 1.0.19 |
| 600 | 600 | */ |
| 601 | - public function new_payment_method_entry( $form ) { |
|
| 601 | + public function new_payment_method_entry($form) { |
|
| 602 | 602 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
| 603 | 603 | } |
| 604 | 604 | |
@@ -608,16 +608,16 @@ discard block |
||
| 608 | 608 | * @since 1.0.19 |
| 609 | 609 | */ |
| 610 | 610 | public function saved_payment_methods() { |
| 611 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
| 611 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
| 612 | 612 | |
| 613 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
| 614 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 613 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
| 614 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | $html .= $this->get_new_payment_method_option_html(); |
| 618 | 618 | $html .= '</ul>'; |
| 619 | 619 | |
| 620 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 620 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | * @param array $token Payment Token. |
| 628 | 628 | * @return string Generated payment method HTML |
| 629 | 629 | */ |
| 630 | - public function get_saved_payment_method_option_html( $token ) { |
|
| 630 | + public function get_saved_payment_method_option_html($token) { |
|
| 631 | 631 | |
| 632 | 632 | return sprintf( |
| 633 | 633 | '<li class="getpaid-payment-method form-group"> |
@@ -636,11 +636,11 @@ discard block |
||
| 636 | 636 | <span>%3$s</span> |
| 637 | 637 | </label> |
| 638 | 638 | </li>', |
| 639 | - esc_attr( $this->id ), |
|
| 640 | - esc_attr( $token['id'] ), |
|
| 641 | - esc_html( $token['name'] ), |
|
| 642 | - checked( empty( $token['default'] ), false, false ), |
|
| 643 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
| 639 | + esc_attr($this->id), |
|
| 640 | + esc_attr($token['id']), |
|
| 641 | + esc_html($token['name']), |
|
| 642 | + checked(empty($token['default']), false, false), |
|
| 643 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
| 644 | 644 | ); |
| 645 | 645 | |
| 646 | 646 | } |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | */ |
| 653 | 653 | public function get_new_payment_method_option_html() { |
| 654 | 654 | |
| 655 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 655 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
| 656 | 656 | |
| 657 | 657 | return sprintf( |
| 658 | 658 | '<li class="getpaid-new-payment-method"> |
@@ -661,8 +661,8 @@ discard block |
||
| 661 | 661 | <span>%2$s</span> |
| 662 | 662 | </label> |
| 663 | 663 | </li>', |
| 664 | - esc_attr( $this->id ), |
|
| 665 | - esc_html( $label ) |
|
| 664 | + esc_attr($this->id), |
|
| 665 | + esc_html($label) |
|
| 666 | 666 | ); |
| 667 | 667 | |
| 668 | 668 | } |
@@ -677,10 +677,10 @@ discard block |
||
| 677 | 677 | return aui()->input( |
| 678 | 678 | array( |
| 679 | 679 | 'type' => 'checkbox', |
| 680 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
| 681 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
| 680 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
| 681 | + 'id' => esc_attr(uniqid($this->id)), |
|
| 682 | 682 | 'required' => false, |
| 683 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
| 683 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
| 684 | 684 | 'value' => 'true', |
| 685 | 685 | 'checked' => true, |
| 686 | 686 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -694,9 +694,9 @@ discard block |
||
| 694 | 694 | * |
| 695 | 695 | * @return array |
| 696 | 696 | */ |
| 697 | - public function register_gateway( $gateways ) { |
|
| 697 | + public function register_gateway($gateways) { |
|
| 698 | 698 | |
| 699 | - $gateways[ $this->id ] = array( |
|
| 699 | + $gateways[$this->id] = array( |
|
| 700 | 700 | |
| 701 | 701 | 'admin_label' => $this->method_title, |
| 702 | 702 | 'checkout_label' => $this->title, |
@@ -714,13 +714,13 @@ discard block |
||
| 714 | 714 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
| 715 | 715 | * @return bool |
| 716 | 716 | */ |
| 717 | - public function is_sandbox( $invoice = null ) { |
|
| 717 | + public function is_sandbox($invoice = null) { |
|
| 718 | 718 | |
| 719 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 719 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
| 720 | 720 | return $invoice->get_mode() == 'test'; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - return wpinv_is_test_mode( $this->id ); |
|
| 723 | + return wpinv_is_test_mode($this->id); |
|
| 724 | 724 | |
| 725 | 725 | } |
| 726 | 726 | |
@@ -738,15 +738,15 @@ discard block |
||
| 738 | 738 | * |
| 739 | 739 | * @return bool |
| 740 | 740 | */ |
| 741 | - public function validate_currency( $validation, $currency ) { |
|
| 741 | + public function validate_currency($validation, $currency) { |
|
| 742 | 742 | |
| 743 | 743 | // Required currencies. |
| 744 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 744 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
| 745 | 745 | return false; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // Excluded currencies. |
| 749 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 749 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
| 750 | 750 | return false; |
| 751 | 751 | } |
| 752 | 752 | |
@@ -757,13 +757,13 @@ discard block |
||
| 757 | 757 | * Displays an error |
| 758 | 758 | * |
| 759 | 759 | */ |
| 760 | - public function show_error( $code, $message, $type ) { |
|
| 760 | + public function show_error($code, $message, $type) { |
|
| 761 | 761 | |
| 762 | - if ( is_admin() ) { |
|
| 763 | - getpaid_admin()->{"show_$type"}( $message ); |
|
| 762 | + if (is_admin()) { |
|
| 763 | + getpaid_admin()->{"show_$type"}($message); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - wpinv_set_error( $code, $message, $type ); |
|
| 766 | + wpinv_set_error($code, $message, $type); |
|
| 767 | 767 | |
| 768 | 768 | } |
| 769 | 769 | |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
| 197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
| 198 | 198 | |
| 199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
| 200 | - $tip = wpinv_clean( $option['desc'] ); |
|
| 201 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
| 202 | - unset( $option['desc'] ); |
|
| 203 | - } |
|
| 199 | + if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
| 200 | + $tip = wpinv_clean( $option['desc'] ); |
|
| 201 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
| 202 | + unset( $option['desc'] ); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | 205 | // Loop through all tabs. |
| 206 | 206 | add_settings_field( |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
| 228 | 228 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
| 229 | 229 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
| 230 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 231 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 232 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 230 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 231 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 232 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 233 | 233 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
| 234 | 234 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
| 235 | 235 | ) |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return array |
| 244 | 244 | */ |
| 245 | 245 | function wpinv_get_registered_settings() { |
| 246 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 246 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function wpinv_settings_sanitize( $input = array() ) { |
| 264 | 264 | |
| 265 | - $wpinv_options = wpinv_get_options(); |
|
| 266 | - $raw_referrer = wp_get_raw_referer(); |
|
| 265 | + $wpinv_options = wpinv_get_options(); |
|
| 266 | + $raw_referrer = wp_get_raw_referer(); |
|
| 267 | 267 | |
| 268 | 268 | if ( empty( $raw_referrer ) ) { |
| 269 | 269 | return $input; |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | wp_parse_str( $raw_referrer, $referrer ); |
| 273 | 273 | |
| 274 | - if ( empty( $referrer['tab'] ) ) { |
|
| 274 | + if ( empty( $referrer['tab'] ) ) { |
|
| 275 | 275 | return $input; |
| 276 | - } |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | 278 | $settings = wpinv_get_registered_settings(); |
| 279 | 279 | $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
@@ -295,10 +295,10 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | // General filter |
| 298 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 298 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 299 | 299 | |
| 300 | - // Key specific filter. |
|
| 301 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 300 | + // Key specific filter. |
|
| 301 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -354,14 +354,14 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | foreach ( $new_rates as $rate ) { |
| 356 | 356 | |
| 357 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 358 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 359 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 360 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 361 | - $rate['global'] = empty( $rate['state'] ); |
|
| 362 | - $tax_rates[] = $rate; |
|
| 357 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 358 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 359 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 360 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 361 | + $rate['global'] = empty( $rate['state'] ); |
|
| 362 | + $tax_rates[] = $rate; |
|
| 363 | 363 | |
| 364 | - } |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | 366 | update_option( 'wpinv_tax_rates', $tax_rates ); |
| 367 | 367 | |
@@ -379,11 +379,11 @@ discard block |
||
| 379 | 379 | $tabs['general'] = __( 'General', 'invoicing' ); |
| 380 | 380 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
| 381 | 381 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
| 382 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 382 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 383 | 383 | |
| 384 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 385 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 386 | - } |
|
| 384 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 385 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | 388 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
| 389 | 389 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | ) ), |
| 422 | 422 | 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
| 423 | 423 | 'main' => __( 'Tax Settings', 'invoicing' ), |
| 424 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 425 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
| 424 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 425 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
| 426 | 426 | ) ), |
| 427 | 427 | 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
| 428 | 428 | 'main' => __( 'Email Settings', 'invoicing' ), |
| 429 | - ) ), |
|
| 429 | + ) ), |
|
| 430 | 430 | |
| 431 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 431 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 432 | 432 | |
| 433 | 433 | 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
| 434 | 434 | 'main' => __( 'Privacy policy', 'invoicing' ), |
@@ -448,48 +448,48 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
| 451 | - $pages_options = array(); |
|
| 451 | + $pages_options = array(); |
|
| 452 | 452 | |
| 453 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 454 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 455 | - } |
|
| 453 | + if( $default_label !== NULL && $default_label !== false ) { |
|
| 454 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | - $pages = get_pages(); |
|
| 458 | - if ( $pages ) { |
|
| 459 | - foreach ( $pages as $page ) { |
|
| 460 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 457 | + $pages = get_pages(); |
|
| 458 | + if ( $pages ) { |
|
| 459 | + foreach ( $pages as $page ) { |
|
| 460 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 461 | 461 | $pages_options[ $page->ID ] = $title; |
| 462 | - } |
|
| 463 | - } |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - return $pages_options; |
|
| 465 | + return $pages_options; |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | function wpinv_header_callback( $args ) { |
| 469 | - if ( !empty( $args['desc'] ) ) { |
|
| 469 | + if ( !empty( $args['desc'] ) ) { |
|
| 470 | 470 | echo $args['desc']; |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | function wpinv_hidden_callback( $args ) { |
| 475 | 475 | |
| 476 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 477 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 476 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 477 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 478 | 478 | |
| 479 | - if ( isset( $args['set_value'] ) ) { |
|
| 480 | - $value = $args['set_value']; |
|
| 481 | - } |
|
| 479 | + if ( isset( $args['set_value'] ) ) { |
|
| 480 | + $value = $args['set_value']; |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 484 | - $args['readonly'] = true; |
|
| 485 | - $name = ''; |
|
| 486 | - } else { |
|
| 487 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 488 | - } |
|
| 483 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 484 | + $args['readonly'] = true; |
|
| 485 | + $name = ''; |
|
| 486 | + } else { |
|
| 487 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 490 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 491 | 491 | |
| 492 | - echo $html; |
|
| 492 | + echo $html; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -497,12 +497,12 @@ discard block |
||
| 497 | 497 | */ |
| 498 | 498 | function wpinv_checkbox_callback( $args ) { |
| 499 | 499 | |
| 500 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 501 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 502 | - $id = esc_attr( $args['id'] ); |
|
| 500 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 501 | + $std = wpinv_get_option( $args['id'], $std ); |
|
| 502 | + $id = esc_attr( $args['id'] ); |
|
| 503 | 503 | |
| 504 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 505 | - ?> |
|
| 504 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 505 | + ?> |
|
| 506 | 506 | <fieldset> |
| 507 | 507 | <label> |
| 508 | 508 | <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -514,75 +514,75 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | function wpinv_multicheck_callback( $args ) { |
| 516 | 516 | |
| 517 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 518 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 517 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 518 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 519 | 519 | |
| 520 | - if ( ! empty( $args['options'] ) ) { |
|
| 520 | + if ( ! empty( $args['options'] ) ) { |
|
| 521 | 521 | |
| 522 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 523 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 522 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 523 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 524 | 524 | |
| 525 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 525 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 526 | 526 | foreach( $args['options'] as $key => $option ): |
| 527 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 528 | - if ( in_array( $sanitize_key, $value ) ) { |
|
| 529 | - $enabled = $sanitize_key; |
|
| 530 | - } else { |
|
| 531 | - $enabled = NULL; |
|
| 532 | - } |
|
| 533 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 534 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 535 | - endforeach; |
|
| 536 | - echo '</div>'; |
|
| 537 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 538 | - } |
|
| 527 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 528 | + if ( in_array( $sanitize_key, $value ) ) { |
|
| 529 | + $enabled = $sanitize_key; |
|
| 530 | + } else { |
|
| 531 | + $enabled = NULL; |
|
| 532 | + } |
|
| 533 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 534 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 535 | + endforeach; |
|
| 536 | + echo '</div>'; |
|
| 537 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 538 | + } |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | function wpinv_payment_icons_callback( $args ) { |
| 542 | 542 | |
| 543 | 543 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 544 | - $value = wpinv_get_option( $args['id'], false); |
|
| 544 | + $value = wpinv_get_option( $args['id'], false); |
|
| 545 | 545 | |
| 546 | - if ( ! empty( $args['options'] ) ) { |
|
| 547 | - foreach( $args['options'] as $key => $option ) { |
|
| 546 | + if ( ! empty( $args['options'] ) ) { |
|
| 547 | + foreach( $args['options'] as $key => $option ) { |
|
| 548 | 548 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 549 | 549 | |
| 550 | - if( empty( $value ) ) { |
|
| 551 | - $enabled = $option; |
|
| 552 | - } else { |
|
| 553 | - $enabled = NULL; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 557 | - |
|
| 558 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 559 | - |
|
| 560 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 561 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 562 | - } else { |
|
| 563 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 564 | - |
|
| 565 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 566 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 567 | - } else { |
|
| 568 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 569 | - $content_dir = WP_CONTENT_DIR; |
|
| 570 | - |
|
| 571 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 572 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 573 | - $image = wp_normalize_path( $image ); |
|
| 574 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 581 | - } |
|
| 582 | - echo $option . '</label>'; |
|
| 583 | - } |
|
| 584 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 585 | - } |
|
| 550 | + if( empty( $value ) ) { |
|
| 551 | + $enabled = $option; |
|
| 552 | + } else { |
|
| 553 | + $enabled = NULL; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 557 | + |
|
| 558 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 559 | + |
|
| 560 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 561 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 562 | + } else { |
|
| 563 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 564 | + |
|
| 565 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 566 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 567 | + } else { |
|
| 568 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 569 | + $content_dir = WP_CONTENT_DIR; |
|
| 570 | + |
|
| 571 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 572 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 573 | + $image = wp_normalize_path( $image ); |
|
| 574 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 581 | + } |
|
| 582 | + echo $option . '</label>'; |
|
| 583 | + } |
|
| 584 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 585 | + } |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -590,9 +590,9 @@ discard block |
||
| 590 | 590 | */ |
| 591 | 591 | function wpinv_radio_callback( $args ) { |
| 592 | 592 | |
| 593 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 594 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 595 | - ?> |
|
| 593 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 594 | + $std = wpinv_get_option( $args['id'], $std ); |
|
| 595 | + ?> |
|
| 596 | 596 | <fieldset> |
| 597 | 597 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
| 598 | 598 | <?php foreach( $args['options'] as $key => $option ) : ?> |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | </ul> |
| 607 | 607 | </fieldset> |
| 608 | 608 | <?php |
| 609 | - getpaid_settings_description_callback( $args ); |
|
| 609 | + getpaid_settings_description_callback( $args ); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
@@ -614,10 +614,10 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | function getpaid_settings_description_callback( $args ) { |
| 616 | 616 | |
| 617 | - if ( ! empty( $args['desc'] ) ) { |
|
| 618 | - $description = wp_kses_post( $args['desc'] ); |
|
| 619 | - echo "<p class='description'>$description</p>"; |
|
| 620 | - } |
|
| 617 | + if ( ! empty( $args['desc'] ) ) { |
|
| 618 | + $description = wp_kses_post( $args['desc'] ); |
|
| 619 | + echo "<p class='description'>$description</p>"; |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | } |
| 623 | 623 | |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | */ |
| 627 | 627 | function wpinv_gateways_callback() { |
| 628 | 628 | |
| 629 | - ?> |
|
| 629 | + ?> |
|
| 630 | 630 | </td> |
| 631 | 631 | </tr> |
| 632 | 632 | <tr class="bsui"> |
@@ -640,22 +640,22 @@ discard block |
||
| 640 | 640 | |
| 641 | 641 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 642 | 642 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
| 643 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 644 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 643 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 644 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 645 | 645 | |
| 646 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 646 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 647 | 647 | |
| 648 | - foreach ( $args['options'] as $key => $option ) : |
|
| 649 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 648 | + foreach ( $args['options'] as $key => $option ) : |
|
| 649 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 650 | 650 | $selected = selected( $key, $args['selected'], false ); |
| 651 | 651 | } else { |
| 652 | 652 | $selected = selected( $key, $value, false ); |
| 653 | 653 | } |
| 654 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 655 | - endforeach; |
|
| 654 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 655 | + endforeach; |
|
| 656 | 656 | |
| 657 | - echo '</select>'; |
|
| 658 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 657 | + echo '</select>'; |
|
| 658 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -666,29 +666,29 @@ discard block |
||
| 666 | 666 | */ |
| 667 | 667 | function wpinv_settings_attrs_helper( $args ) { |
| 668 | 668 | |
| 669 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 670 | - $id = esc_attr( $args['id'] ); |
|
| 671 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
| 669 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 670 | + $id = esc_attr( $args['id'] ); |
|
| 671 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
| 672 | 672 | |
| 673 | - if ( ! empty( $args['faux'] ) ) { |
|
| 674 | - $args['readonly'] = true; |
|
| 675 | - $name = ''; |
|
| 676 | - } else { |
|
| 677 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 678 | - $name = "wpinv_settings[$id]"; |
|
| 679 | - } |
|
| 673 | + if ( ! empty( $args['faux'] ) ) { |
|
| 674 | + $args['readonly'] = true; |
|
| 675 | + $name = ''; |
|
| 676 | + } else { |
|
| 677 | + $value = wpinv_get_option( $args['id'], $value ); |
|
| 678 | + $name = "wpinv_settings[$id]"; |
|
| 679 | + } |
|
| 680 | 680 | |
| 681 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 682 | - $class = esc_attr( $args['class'] ); |
|
| 683 | - $style = esc_attr( $args['style'] ); |
|
| 684 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 681 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 682 | + $class = esc_attr( $args['class'] ); |
|
| 683 | + $style = esc_attr( $args['style'] ); |
|
| 684 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 685 | 685 | |
| 686 | - $onchange = ''; |
|
| 686 | + $onchange = ''; |
|
| 687 | 687 | if ( ! empty( $args['onchange'] ) ) { |
| 688 | 688 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
| 689 | - } |
|
| 689 | + } |
|
| 690 | 690 | |
| 691 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
| 691 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /** |
@@ -696,11 +696,11 @@ discard block |
||
| 696 | 696 | */ |
| 697 | 697 | function wpinv_text_callback( $args ) { |
| 698 | 698 | |
| 699 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 700 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 701 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 699 | + $desc = wp_kses_post( $args['desc'] ); |
|
| 700 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 701 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
| 702 | 702 | |
| 703 | - ?> |
|
| 703 | + ?> |
|
| 704 | 704 | <label style="width: 100%;"> |
| 705 | 705 | <input type="text" <?php echo $attr; ?>> |
| 706 | 706 | <?php echo $desc; ?> |
@@ -714,14 +714,14 @@ discard block |
||
| 714 | 714 | */ |
| 715 | 715 | function wpinv_number_callback( $args ) { |
| 716 | 716 | |
| 717 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 718 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 719 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 720 | - $max = intval( $args['max'] ); |
|
| 721 | - $min = intval( $args['min'] ); |
|
| 722 | - $step = floatval( $args['step'] ); |
|
| 717 | + $desc = wp_kses_post( $args['desc'] ); |
|
| 718 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 719 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
| 720 | + $max = intval( $args['max'] ); |
|
| 721 | + $min = intval( $args['min'] ); |
|
| 722 | + $step = floatval( $args['step'] ); |
|
| 723 | 723 | |
| 724 | - ?> |
|
| 724 | + ?> |
|
| 725 | 725 | <label style="width: 100%;"> |
| 726 | 726 | <input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>> |
| 727 | 727 | <?php echo $desc; ?> |
@@ -733,36 +733,36 @@ discard block |
||
| 733 | 733 | function wpinv_textarea_callback( $args ) { |
| 734 | 734 | |
| 735 | 735 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 736 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 737 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 736 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 737 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 738 | 738 | |
| 739 | 739 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 740 | 740 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 741 | 741 | |
| 742 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 743 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 742 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 743 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 744 | 744 | |
| 745 | - echo $html; |
|
| 745 | + echo $html; |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | function wpinv_password_callback( $args ) { |
| 749 | 749 | |
| 750 | 750 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 751 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 752 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 751 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 752 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 753 | 753 | |
| 754 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 755 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 756 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 754 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 755 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 756 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 757 | 757 | |
| 758 | - echo $html; |
|
| 758 | + echo $html; |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | function wpinv_missing_callback($args) { |
| 762 | - printf( |
|
| 763 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 764 | - '<strong>' . $args['id'] . '</strong>' |
|
| 765 | - ); |
|
| 762 | + printf( |
|
| 763 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 764 | + '<strong>' . $args['id'] . '</strong>' |
|
| 765 | + ); |
|
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | /** |
@@ -770,14 +770,14 @@ discard block |
||
| 770 | 770 | */ |
| 771 | 771 | function wpinv_select_callback( $args ) { |
| 772 | 772 | |
| 773 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 774 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 775 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 776 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 777 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 778 | - $rand = uniqid( 'random_id' ); |
|
| 773 | + $desc = wp_kses_post( $args['desc'] ); |
|
| 774 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 775 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
| 776 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 777 | + $value = wpinv_get_option( $args['id'], $value ); |
|
| 778 | + $rand = uniqid( 'random_id' ); |
|
| 779 | 779 | |
| 780 | - ?> |
|
| 780 | + ?> |
|
| 781 | 781 | <label style="width: 100%;"> |
| 782 | 782 | <select <?php echo $attr; ?>> |
| 783 | 783 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -810,104 +810,104 @@ discard block |
||
| 810 | 810 | function wpinv_color_select_callback( $args ) { |
| 811 | 811 | |
| 812 | 812 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 813 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 814 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 813 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 814 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 815 | 815 | |
| 816 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 816 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 817 | 817 | |
| 818 | - foreach ( $args['options'] as $option => $color ) { |
|
| 819 | - $selected = selected( $option, $value, false ); |
|
| 820 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 821 | - } |
|
| 818 | + foreach ( $args['options'] as $option => $color ) { |
|
| 819 | + $selected = selected( $option, $value, false ); |
|
| 820 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | - $html .= '</select>'; |
|
| 824 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 823 | + $html .= '</select>'; |
|
| 824 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 825 | 825 | |
| 826 | - echo $html; |
|
| 826 | + echo $html; |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | function wpinv_rich_editor_callback( $args ) { |
| 830 | - global $wp_version; |
|
| 830 | + global $wp_version; |
|
| 831 | 831 | |
| 832 | 832 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 833 | 833 | |
| 834 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 835 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 834 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 835 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 836 | 836 | |
| 837 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 838 | - $value = $std; |
|
| 839 | - } |
|
| 837 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 838 | + $value = $std; |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 841 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 842 | 842 | |
| 843 | - $html = '<div class="getpaid-settings-editor-input">'; |
|
| 844 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 845 | - ob_start(); |
|
| 846 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
| 847 | - $html .= ob_get_clean(); |
|
| 848 | - } else { |
|
| 849 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 850 | - } |
|
| 843 | + $html = '<div class="getpaid-settings-editor-input">'; |
|
| 844 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 845 | + ob_start(); |
|
| 846 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
| 847 | + $html .= ob_get_clean(); |
|
| 848 | + } else { |
|
| 849 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 852 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 853 | 853 | |
| 854 | - echo $html; |
|
| 854 | + echo $html; |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | function wpinv_upload_callback( $args ) { |
| 858 | 858 | |
| 859 | 859 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 860 | 860 | |
| 861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 861 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 862 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 863 | 863 | |
| 864 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 865 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 866 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 867 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 864 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 865 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 866 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 867 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 868 | 868 | |
| 869 | - echo $html; |
|
| 869 | + echo $html; |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | function wpinv_color_callback( $args ) { |
| 873 | 873 | |
| 874 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 875 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 874 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 875 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 876 | 876 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 877 | 877 | |
| 878 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
| 879 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 878 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
| 879 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 880 | 880 | |
| 881 | - echo $html; |
|
| 881 | + echo $html; |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | function wpinv_country_states_callback($args) { |
| 885 | 885 | |
| 886 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 887 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 886 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 887 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 888 | 888 | |
| 889 | 889 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 890 | 890 | |
| 891 | - if ( isset( $args['placeholder'] ) ) { |
|
| 892 | - $placeholder = $args['placeholder']; |
|
| 893 | - } else { |
|
| 894 | - $placeholder = ''; |
|
| 895 | - } |
|
| 891 | + if ( isset( $args['placeholder'] ) ) { |
|
| 892 | + $placeholder = $args['placeholder']; |
|
| 893 | + } else { |
|
| 894 | + $placeholder = ''; |
|
| 895 | + } |
|
| 896 | 896 | |
| 897 | - $states = wpinv_get_country_states(); |
|
| 897 | + $states = wpinv_get_country_states(); |
|
| 898 | 898 | |
| 899 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 900 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 899 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 900 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 901 | 901 | |
| 902 | - foreach ( $states as $option => $name ) { |
|
| 903 | - $selected = selected( $option, $value, false ); |
|
| 904 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 905 | - } |
|
| 902 | + foreach ( $states as $option => $name ) { |
|
| 903 | + $selected = selected( $option, $value, false ); |
|
| 904 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 905 | + } |
|
| 906 | 906 | |
| 907 | - $html .= '</select>'; |
|
| 908 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 907 | + $html .= '</select>'; |
|
| 908 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 909 | 909 | |
| 910 | - echo $html; |
|
| 910 | + echo $html; |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | /** |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | function wpinv_tax_rates_callback() { |
| 917 | 917 | |
| 918 | - ?> |
|
| 918 | + ?> |
|
| 919 | 919 | </td> |
| 920 | 920 | </tr> |
| 921 | 921 | <tr class="bsui"> |
@@ -930,17 +930,17 @@ discard block |
||
| 930 | 930 | * Displays a tax rate' edit row. |
| 931 | 931 | */ |
| 932 | 932 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
| 933 | - ob_start(); |
|
| 933 | + ob_start(); |
|
| 934 | 934 | |
| 935 | - $key = sanitize_key( $key ); |
|
| 936 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 937 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 935 | + $key = sanitize_key( $key ); |
|
| 936 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 937 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 938 | 938 | |
| 939 | - if ( $echo ) { |
|
| 940 | - echo ob_get_clean(); |
|
| 941 | - } else { |
|
| 942 | - return ob_get_clean(); |
|
| 943 | - } |
|
| 939 | + if ( $echo ) { |
|
| 940 | + echo ob_get_clean(); |
|
| 941 | + } else { |
|
| 942 | + return ob_get_clean(); |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | 945 | } |
| 946 | 946 | |
@@ -968,14 +968,14 @@ discard block |
||
| 968 | 968 | </td> |
| 969 | 969 | <td> |
| 970 | 970 | <a href="<?php |
| 971 | - echo esc_url( |
|
| 972 | - wp_nonce_url( |
|
| 973 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 974 | - 'getpaid-nonce', |
|
| 975 | - 'getpaid-nonce' |
|
| 976 | - ) |
|
| 977 | - ); |
|
| 978 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 971 | + echo esc_url( |
|
| 972 | + wp_nonce_url( |
|
| 973 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 974 | + 'getpaid-nonce', |
|
| 975 | + 'getpaid-nonce' |
|
| 976 | + ) |
|
| 977 | + ); |
|
| 978 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 979 | 979 | </td> |
| 980 | 980 | </tr> |
| 981 | 981 | <tr> |
@@ -985,14 +985,14 @@ discard block |
||
| 985 | 985 | </td> |
| 986 | 986 | <td> |
| 987 | 987 | <a href="<?php |
| 988 | - echo esc_url( |
|
| 989 | - wp_nonce_url( |
|
| 990 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 991 | - 'getpaid-nonce', |
|
| 992 | - 'getpaid-nonce' |
|
| 993 | - ) |
|
| 994 | - ); |
|
| 995 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 988 | + echo esc_url( |
|
| 989 | + wp_nonce_url( |
|
| 990 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 991 | + 'getpaid-nonce', |
|
| 992 | + 'getpaid-nonce' |
|
| 993 | + ) |
|
| 994 | + ); |
|
| 995 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 996 | 996 | </td> |
| 997 | 997 | </tr> |
| 998 | 998 | <tr> |
@@ -1002,14 +1002,14 @@ discard block |
||
| 1002 | 1002 | </td> |
| 1003 | 1003 | <td> |
| 1004 | 1004 | <a href="<?php |
| 1005 | - echo esc_url( |
|
| 1006 | - wp_nonce_url( |
|
| 1007 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 1008 | - 'getpaid-nonce', |
|
| 1009 | - 'getpaid-nonce' |
|
| 1010 | - ) |
|
| 1011 | - ); |
|
| 1012 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 1005 | + echo esc_url( |
|
| 1006 | + wp_nonce_url( |
|
| 1007 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 1008 | + 'getpaid-nonce', |
|
| 1009 | + 'getpaid-nonce' |
|
| 1010 | + ) |
|
| 1011 | + ); |
|
| 1012 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 1013 | 1013 | </td> |
| 1014 | 1014 | </tr> |
| 1015 | 1015 | |
@@ -1020,14 +1020,14 @@ discard block |
||
| 1020 | 1020 | </td> |
| 1021 | 1021 | <td> |
| 1022 | 1022 | <a href="<?php |
| 1023 | - echo esc_url( |
|
| 1024 | - wp_nonce_url( |
|
| 1025 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 1026 | - 'getpaid-nonce', |
|
| 1027 | - 'getpaid-nonce' |
|
| 1028 | - ) |
|
| 1029 | - ); |
|
| 1030 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
| 1023 | + echo esc_url( |
|
| 1024 | + wp_nonce_url( |
|
| 1025 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 1026 | + 'getpaid-nonce', |
|
| 1027 | + 'getpaid-nonce' |
|
| 1028 | + ) |
|
| 1029 | + ); |
|
| 1030 | + ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
| 1031 | 1031 | </td> |
| 1032 | 1032 | </tr> |
| 1033 | 1033 | |
@@ -1041,19 +1041,19 @@ discard block |
||
| 1041 | 1041 | |
| 1042 | 1042 | |
| 1043 | 1043 | function wpinv_descriptive_text_callback( $args ) { |
| 1044 | - echo wp_kses_post( $args['desc'] ); |
|
| 1044 | + echo wp_kses_post( $args['desc'] ); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | function wpinv_raw_html_callback( $args ) { |
| 1048 | - echo $args['desc']; |
|
| 1048 | + echo $args['desc']; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | function wpinv_hook_callback( $args ) { |
| 1052 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1052 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | function wpinv_set_settings_cap() { |
| 1056 | - return wpinv_get_capability(); |
|
| 1056 | + return wpinv_get_capability(); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
| 1059 | 1059 | |
@@ -1087,15 +1087,15 @@ discard block |
||
| 1087 | 1087 | */ |
| 1088 | 1088 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
| 1089 | 1089 | |
| 1090 | - $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
| 1091 | - $link = sprintf( |
|
| 1092 | - '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
| 1093 | - $url, |
|
| 1094 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1095 | - ); |
|
| 1090 | + $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
| 1091 | + $link = sprintf( |
|
| 1092 | + '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
| 1093 | + $url, |
|
| 1094 | + esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1095 | + ); |
|
| 1096 | 1096 | |
| 1097 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1097 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1098 | 1098 | |
| 1099 | - return "$description $link"; |
|
| 1099 | + return "$description $link"; |
|
| 1100 | 1100 | |
| 1101 | 1101 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @since 1.0.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | function wpinv_get_settings() { |
| 17 | 17 | $defaults = array(); |
| 18 | 18 | |
| 19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
| 19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
| 20 | 20 | |
| 21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
| 21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
| 22 | 22 | |
| 23 | - foreach ( $section_settings as $key => $setting ) { |
|
| 24 | - if ( isset( $setting['std'] ) ) { |
|
| 25 | - $defaults[ $key ] = $setting['std']; |
|
| 23 | + foreach ($section_settings as $key => $setting) { |
|
| 24 | + if (isset($setting['std'])) { |
|
| 25 | + $defaults[$key] = $setting['std']; |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | global $wpinv_options; |
| 44 | 44 | |
| 45 | 45 | // Try fetching the saved options. |
| 46 | - if ( empty( $wpinv_options ) ) { |
|
| 47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
| 46 | + if (empty($wpinv_options)) { |
|
| 47 | + $wpinv_options = get_option('wpinv_settings'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
| 51 | - if ( ! is_array( $wpinv_options ) ) { |
|
| 51 | + if (!is_array($wpinv_options)) { |
|
| 52 | 52 | $wpinv_options = array(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
| 63 | 63 | * @return mixed |
| 64 | 64 | */ |
| 65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
| 65 | +function wpinv_get_option($key = '', $default = false) { |
|
| 66 | 66 | |
| 67 | 67 | $options = wpinv_get_options(); |
| 68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
| 68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
| 69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
| 70 | 70 | |
| 71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
| 71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | * @param array $options the new options. |
| 78 | 78 | * @return bool |
| 79 | 79 | */ |
| 80 | -function wpinv_update_options( $options ) { |
|
| 80 | +function wpinv_update_options($options) { |
|
| 81 | 81 | global $wpinv_options; |
| 82 | 82 | |
| 83 | 83 | // update the option. |
| 84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
| 84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
| 85 | 85 | $wpinv_options = $options; |
| 86 | 86 | return true; |
| 87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | * @param mixed $value The setting value. |
| 97 | 97 | * @return bool |
| 98 | 98 | */ |
| 99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
| 99 | +function wpinv_update_option($key = '', $value = false) { |
|
| 100 | 100 | |
| 101 | 101 | // If no key, exit. |
| 102 | - if ( empty( $key ) ) { |
|
| 102 | + if (empty($key)) { |
|
| 103 | 103 | return false; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Maybe delete the option instead. |
| 107 | - if ( is_null( $value ) ) { |
|
| 108 | - return wpinv_delete_option( $key ); |
|
| 107 | + if (is_null($value)) { |
|
| 108 | + return wpinv_delete_option($key); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Prepare the new options. |
| 112 | 112 | $options = wpinv_get_options(); |
| 113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
| 113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
| 114 | 114 | |
| 115 | 115 | // Save the new options. |
| 116 | - return wpinv_update_options( $options ); |
|
| 116 | + return wpinv_update_options($options); |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
| 123 | 123 | * @param string $key the setting key. |
| 124 | 124 | * @return bool |
| 125 | 125 | */ |
| 126 | -function wpinv_delete_option( $key = '' ) { |
|
| 126 | +function wpinv_delete_option($key = '') { |
|
| 127 | 127 | |
| 128 | 128 | // If no key, exit |
| 129 | - if ( empty( $key ) ) { |
|
| 129 | + if (empty($key)) { |
|
| 130 | 130 | return false; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $options = wpinv_get_options(); |
| 134 | 134 | |
| 135 | - if ( isset( $options[ $key ] ) ) { |
|
| 136 | - unset( $options[ $key ] ); |
|
| 137 | - return wpinv_update_options( $options ); |
|
| 135 | + if (isset($options[$key])) { |
|
| 136 | + unset($options[$key]); |
|
| 137 | + return wpinv_update_options($options); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | function wpinv_register_settings() { |
| 149 | 149 | |
| 150 | 150 | // Loop through all tabs. |
| 151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
| 151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
| 152 | 152 | |
| 153 | 153 | // In each tab, loop through sections. |
| 154 | - foreach ( $sections as $section => $settings ) { |
|
| 154 | + foreach ($sections as $section => $settings) { |
|
| 155 | 155 | |
| 156 | 156 | // Check for backwards compatibility |
| 157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
| 158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
| 157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
| 158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
| 159 | 159 | $section = 'main'; |
| 160 | 160 | $settings = $sections; |
| 161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | - foreach ( $settings as $option ) { |
|
| 172 | - if ( ! empty( $option['id'] ) ) { |
|
| 173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
| 171 | + foreach ($settings as $option) { |
|
| 172 | + if (!empty($option['id'])) { |
|
| 173 | + wpinv_register_settings_option($tab, $section, $option); |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Creates our settings in the options table. |
| 181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
| 181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
| 182 | 182 | } |
| 183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
| 183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * Register a single settings option. |
@@ -190,48 +190,48 @@ discard block |
||
| 190 | 190 | * @param string $option |
| 191 | 191 | * |
| 192 | 192 | */ |
| 193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
| 193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
| 194 | 194 | |
| 195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
| 195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
| 196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
| 197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
| 198 | 198 | |
| 199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
| 200 | - $tip = wpinv_clean( $option['desc'] ); |
|
| 199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
| 200 | + $tip = wpinv_clean($option['desc']); |
|
| 201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
| 202 | - unset( $option['desc'] ); |
|
| 202 | + unset($option['desc']); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Loop through all tabs. |
| 206 | 206 | add_settings_field( |
| 207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
| 208 | 208 | $name, |
| 209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
| 209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
| 210 | 210 | $section, |
| 211 | 211 | $section, |
| 212 | 212 | array( |
| 213 | 213 | 'section' => $section, |
| 214 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
| 215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
| 214 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
| 215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
| 216 | 216 | 'name' => $name, |
| 217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 221 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
| 222 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
| 223 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
| 224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
| 230 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 231 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 232 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 233 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
| 234 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
| 217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 221 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
| 222 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
| 223 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
| 224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
| 229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
| 230 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
| 231 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
| 232 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
| 233 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
| 234 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
| 235 | 235 | ) |
| 236 | 236 | ); |
| 237 | 237 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return array |
| 244 | 244 | */ |
| 245 | 245 | function wpinv_get_registered_settings() { |
| 246 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 246 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @return array |
| 253 | 253 | */ |
| 254 | 254 | function getpaid_get_integration_settings() { |
| 255 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
| 255 | + return apply_filters('getpaid_integration_settings', array()); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -260,144 +260,144 @@ discard block |
||
| 260 | 260 | * |
| 261 | 261 | * @return array |
| 262 | 262 | */ |
| 263 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 263 | +function wpinv_settings_sanitize($input = array()) { |
|
| 264 | 264 | |
| 265 | 265 | $wpinv_options = wpinv_get_options(); |
| 266 | 266 | $raw_referrer = wp_get_raw_referer(); |
| 267 | 267 | |
| 268 | - if ( empty( $raw_referrer ) ) { |
|
| 268 | + if (empty($raw_referrer)) { |
|
| 269 | 269 | return $input; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - wp_parse_str( $raw_referrer, $referrer ); |
|
| 272 | + wp_parse_str($raw_referrer, $referrer); |
|
| 273 | 273 | |
| 274 | - if ( empty( $referrer['tab'] ) ) { |
|
| 274 | + if (empty($referrer['tab'])) { |
|
| 275 | 275 | return $input; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | $settings = wpinv_get_registered_settings(); |
| 279 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 280 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 279 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 280 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 281 | 281 | |
| 282 | 282 | $input = $input ? $input : array(); |
| 283 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 284 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 283 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 284 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 285 | 285 | |
| 286 | 286 | // Loop through each setting being saved and pass it through a sanitization filter |
| 287 | - foreach ( $input as $key => $value ) { |
|
| 287 | + foreach ($input as $key => $value) { |
|
| 288 | 288 | |
| 289 | 289 | // Get the setting type (checkbox, select, etc) |
| 290 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
| 290 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
| 291 | 291 | |
| 292 | - if ( $type ) { |
|
| 292 | + if ($type) { |
|
| 293 | 293 | // Field type specific filter |
| 294 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
| 294 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | // General filter |
| 298 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 298 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 299 | 299 | |
| 300 | 300 | // Key specific filter. |
| 301 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 301 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 305 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 306 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 305 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 306 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 307 | 307 | |
| 308 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 308 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 309 | 309 | |
| 310 | - if ( ! empty( $found_settings ) ) { |
|
| 311 | - foreach ( $found_settings as $key => $value ) { |
|
| 310 | + if (!empty($found_settings)) { |
|
| 311 | + foreach ($found_settings as $key => $value) { |
|
| 312 | 312 | |
| 313 | 313 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 314 | - if ( is_numeric( $key ) ) { |
|
| 314 | + if (is_numeric($key)) { |
|
| 315 | 315 | $key = $value['id']; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
| 319 | - unset( $wpinv_options[ $key ] ); |
|
| 318 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
| 319 | + unset($wpinv_options[$key]); |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // Merge our new settings with the existing |
| 325 | - $output = array_merge( $wpinv_options, $input ); |
|
| 325 | + $output = array_merge($wpinv_options, $input); |
|
| 326 | 326 | |
| 327 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 327 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 328 | 328 | |
| 329 | 329 | return $output; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
| 332 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
| 333 | 333 | |
| 334 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 334 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 335 | 335 | return $input; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
| 338 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
| 339 | 339 | // Shows an admin notice about upgrading previous order numbers |
| 340 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
| 340 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | return $input; |
| 344 | 344 | } |
| 345 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
| 345 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
| 346 | 346 | |
| 347 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 348 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 347 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 348 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 349 | 349 | return $input; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
| 352 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
| 353 | 353 | $tax_rates = array(); |
| 354 | 354 | |
| 355 | - foreach ( $new_rates as $rate ) { |
|
| 355 | + foreach ($new_rates as $rate) { |
|
| 356 | 356 | |
| 357 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 358 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 359 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 360 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 361 | - $rate['global'] = empty( $rate['state'] ); |
|
| 357 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
| 358 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
| 359 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
| 360 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
| 361 | + $rate['global'] = empty($rate['state']); |
|
| 362 | 362 | $tax_rates[] = $rate; |
| 363 | 363 | |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 366 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 367 | 367 | |
| 368 | 368 | return $input; |
| 369 | 369 | } |
| 370 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 370 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 371 | 371 | |
| 372 | -function wpinv_sanitize_text_field( $input ) { |
|
| 373 | - return trim( $input ); |
|
| 372 | +function wpinv_sanitize_text_field($input) { |
|
| 373 | + return trim($input); |
|
| 374 | 374 | } |
| 375 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
| 375 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
| 376 | 376 | |
| 377 | 377 | function wpinv_get_settings_tabs() { |
| 378 | 378 | $tabs = array(); |
| 379 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 380 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 381 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 382 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 379 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 380 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 381 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 382 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 383 | 383 | |
| 384 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 385 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 384 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
| 385 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
| 389 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 390 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 388 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
| 389 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 390 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 391 | 391 | |
| 392 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 392 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 395 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 396 | 396 | $tabs = false; |
| 397 | 397 | $sections = wpinv_get_registered_settings_sections(); |
| 398 | 398 | |
| 399 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 400 | - $tabs = $sections[ $tab ]; |
|
| 399 | + if ($tab && !empty($sections[$tab])) { |
|
| 400 | + $tabs = $sections[$tab]; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | return $tabs; |
@@ -406,88 +406,88 @@ discard block |
||
| 406 | 406 | function wpinv_get_registered_settings_sections() { |
| 407 | 407 | static $sections = false; |
| 408 | 408 | |
| 409 | - if ( false !== $sections ) { |
|
| 409 | + if (false !== $sections) { |
|
| 410 | 410 | return $sections; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | $sections = array( |
| 414 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
| 415 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 416 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 417 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 418 | - ) ), |
|
| 419 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
| 420 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 421 | - ) ), |
|
| 422 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
| 423 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 424 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 425 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
| 426 | - ) ), |
|
| 427 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
| 428 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 429 | - ) ), |
|
| 430 | - |
|
| 431 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 432 | - |
|
| 433 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
| 434 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
| 435 | - ) ), |
|
| 436 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
| 437 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
| 438 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
| 439 | - ) ), |
|
| 440 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
| 441 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 442 | - ) ), |
|
| 414 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
| 415 | + 'main' => __('General Settings', 'invoicing'), |
|
| 416 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 417 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 418 | + )), |
|
| 419 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
| 420 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 421 | + )), |
|
| 422 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
| 423 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 424 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 425 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
| 426 | + )), |
|
| 427 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
| 428 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 429 | + )), |
|
| 430 | + |
|
| 431 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
| 432 | + |
|
| 433 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
| 434 | + 'main' => __('Privacy policy', 'invoicing'), |
|
| 435 | + )), |
|
| 436 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
| 437 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
| 438 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
| 439 | + )), |
|
| 440 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
| 441 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 442 | + )), |
|
| 443 | 443 | ); |
| 444 | 444 | |
| 445 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 445 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 446 | 446 | |
| 447 | 447 | return $sections; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
| 450 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
| 451 | 451 | $pages_options = array(); |
| 452 | 452 | |
| 453 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 454 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 453 | + if ($default_label !== NULL && $default_label !== false) { |
|
| 454 | + $pages_options = array('' => $default_label); // Blank option |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | $pages = get_pages(); |
| 458 | - if ( $pages ) { |
|
| 459 | - foreach ( $pages as $page ) { |
|
| 458 | + if ($pages) { |
|
| 459 | + foreach ($pages as $page) { |
|
| 460 | 460 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 461 | - $pages_options[ $page->ID ] = $title; |
|
| 461 | + $pages_options[$page->ID] = $title; |
|
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | return $pages_options; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | -function wpinv_header_callback( $args ) { |
|
| 469 | - if ( !empty( $args['desc'] ) ) { |
|
| 468 | +function wpinv_header_callback($args) { |
|
| 469 | + if (!empty($args['desc'])) { |
|
| 470 | 470 | echo $args['desc']; |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | -function wpinv_hidden_callback( $args ) { |
|
| 474 | +function wpinv_hidden_callback($args) { |
|
| 475 | 475 | |
| 476 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 477 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 476 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 477 | + $value = wpinv_get_option($args['id'], $std); |
|
| 478 | 478 | |
| 479 | - if ( isset( $args['set_value'] ) ) { |
|
| 479 | + if (isset($args['set_value'])) { |
|
| 480 | 480 | $value = $args['set_value']; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 483 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 484 | 484 | $args['readonly'] = true; |
| 485 | - $name = ''; |
|
| 485 | + $name = ''; |
|
| 486 | 486 | } else { |
| 487 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 487 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 490 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 491 | 491 | |
| 492 | 492 | echo $html; |
| 493 | 493 | } |
@@ -495,59 +495,59 @@ discard block |
||
| 495 | 495 | /** |
| 496 | 496 | * Displays a checkbox settings callback. |
| 497 | 497 | */ |
| 498 | -function wpinv_checkbox_callback( $args ) { |
|
| 498 | +function wpinv_checkbox_callback($args) { |
|
| 499 | 499 | |
| 500 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 501 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 502 | - $id = esc_attr( $args['id'] ); |
|
| 500 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 501 | + $std = wpinv_get_option($args['id'], $std); |
|
| 502 | + $id = esc_attr($args['id']); |
|
| 503 | 503 | |
| 504 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 504 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
| 505 | 505 | ?> |
| 506 | 506 | <fieldset> |
| 507 | 507 | <label> |
| 508 | - <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
| 509 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
| 508 | + <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
| 509 | + <?php echo wp_kses_post($args['desc']); ?> |
|
| 510 | 510 | </label> |
| 511 | 511 | </fieldset> |
| 512 | 512 | <?php |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | -function wpinv_multicheck_callback( $args ) { |
|
| 515 | +function wpinv_multicheck_callback($args) { |
|
| 516 | 516 | |
| 517 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 518 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 517 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 518 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
| 519 | 519 | |
| 520 | - if ( ! empty( $args['options'] ) ) { |
|
| 520 | + if (!empty($args['options'])) { |
|
| 521 | 521 | |
| 522 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 523 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 522 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
| 523 | + $value = wpinv_get_option($args['id'], $std); |
|
| 524 | 524 | |
| 525 | 525 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
| 526 | - foreach( $args['options'] as $key => $option ): |
|
| 527 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 528 | - if ( in_array( $sanitize_key, $value ) ) { |
|
| 526 | + foreach ($args['options'] as $key => $option): |
|
| 527 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 528 | + if (in_array($sanitize_key, $value)) { |
|
| 529 | 529 | $enabled = $sanitize_key; |
| 530 | 530 | } else { |
| 531 | 531 | $enabled = NULL; |
| 532 | 532 | } |
| 533 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 534 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 533 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
| 534 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
| 535 | 535 | endforeach; |
| 536 | 536 | echo '</div>'; |
| 537 | 537 | echo '<p class="description">' . $args['desc'] . '</p>'; |
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | -function wpinv_payment_icons_callback( $args ) { |
|
| 541 | +function wpinv_payment_icons_callback($args) { |
|
| 542 | 542 | |
| 543 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 544 | - $value = wpinv_get_option( $args['id'], false); |
|
| 543 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 544 | + $value = wpinv_get_option($args['id'], false); |
|
| 545 | 545 | |
| 546 | - if ( ! empty( $args['options'] ) ) { |
|
| 547 | - foreach( $args['options'] as $key => $option ) { |
|
| 548 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 546 | + if (!empty($args['options'])) { |
|
| 547 | + foreach ($args['options'] as $key => $option) { |
|
| 548 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 549 | 549 | |
| 550 | - if( empty( $value ) ) { |
|
| 550 | + if (empty($value)) { |
|
| 551 | 551 | $enabled = $option; |
| 552 | 552 | } else { |
| 553 | 553 | $enabled = NULL; |
@@ -555,67 +555,67 @@ discard block |
||
| 555 | 555 | |
| 556 | 556 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 557 | 557 | |
| 558 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 558 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
| 559 | 559 | |
| 560 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 561 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 560 | + if (wpinv_string_is_image_url($key)) { |
|
| 561 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 562 | 562 | } else { |
| 563 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 563 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 564 | 564 | |
| 565 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 566 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 565 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 566 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 567 | 567 | } else { |
| 568 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 568 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 569 | 569 | $content_dir = WP_CONTENT_DIR; |
| 570 | 570 | |
| 571 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 571 | + if (function_exists('wp_normalize_path')) { |
|
| 572 | 572 | // Replaces backslashes with forward slashes for Windows systems |
| 573 | - $image = wp_normalize_path( $image ); |
|
| 574 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 573 | + $image = wp_normalize_path($image); |
|
| 574 | + $content_dir = wp_normalize_path($content_dir); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 577 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 580 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 581 | 581 | } |
| 582 | 582 | echo $option . '</label>'; |
| 583 | 583 | } |
| 584 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 584 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
| 589 | 589 | * Displays a radio settings field. |
| 590 | 590 | */ |
| 591 | -function wpinv_radio_callback( $args ) { |
|
| 591 | +function wpinv_radio_callback($args) { |
|
| 592 | 592 | |
| 593 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 594 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 593 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 594 | + $std = wpinv_get_option($args['id'], $std); |
|
| 595 | 595 | ?> |
| 596 | 596 | <fieldset> |
| 597 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
| 598 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
| 597 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
| 598 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
| 599 | 599 | <li> |
| 600 | 600 | <label> |
| 601 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
| 602 | - <?php echo wp_kses_post( $option ); ?> |
|
| 601 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
| 602 | + <?php echo wp_kses_post($option); ?> |
|
| 603 | 603 | </label> |
| 604 | 604 | </li> |
| 605 | 605 | <?php endforeach; ?> |
| 606 | 606 | </ul> |
| 607 | 607 | </fieldset> |
| 608 | 608 | <?php |
| 609 | - getpaid_settings_description_callback( $args ); |
|
| 609 | + getpaid_settings_description_callback($args); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
| 613 | 613 | * Displays a description if available. |
| 614 | 614 | */ |
| 615 | -function getpaid_settings_description_callback( $args ) { |
|
| 615 | +function getpaid_settings_description_callback($args) { |
|
| 616 | 616 | |
| 617 | - if ( ! empty( $args['desc'] ) ) { |
|
| 618 | - $description = wp_kses_post( $args['desc'] ); |
|
| 617 | + if (!empty($args['desc'])) { |
|
| 618 | + $description = wp_kses_post($args['desc']); |
|
| 619 | 619 | echo "<p class='description'>$description</p>"; |
| 620 | 620 | } |
| 621 | 621 | |
@@ -631,31 +631,31 @@ discard block |
||
| 631 | 631 | </tr> |
| 632 | 632 | <tr class="bsui"> |
| 633 | 633 | <td colspan="2" class="p-0"> |
| 634 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
| 634 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
| 635 | 635 | |
| 636 | 636 | <?php |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | function wpinv_gateway_select_callback($args) { |
| 640 | 640 | |
| 641 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 642 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 643 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 644 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 641 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 642 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
| 643 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 644 | + $value = wpinv_get_option($args['id'], $std); |
|
| 645 | 645 | |
| 646 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 646 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
| 647 | 647 | |
| 648 | - foreach ( $args['options'] as $key => $option ) : |
|
| 649 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 650 | - $selected = selected( $key, $args['selected'], false ); |
|
| 648 | + foreach ($args['options'] as $key => $option) : |
|
| 649 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 650 | + $selected = selected($key, $args['selected'], false); |
|
| 651 | 651 | } else { |
| 652 | - $selected = selected( $key, $value, false ); |
|
| 652 | + $selected = selected($key, $value, false); |
|
| 653 | 653 | } |
| 654 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 654 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 655 | 655 | endforeach; |
| 656 | 656 | |
| 657 | 657 | echo '</select>'; |
| 658 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 658 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -664,28 +664,28 @@ discard block |
||
| 664 | 664 | * @param array $args |
| 665 | 665 | * @return string |
| 666 | 666 | */ |
| 667 | -function wpinv_settings_attrs_helper( $args ) { |
|
| 667 | +function wpinv_settings_attrs_helper($args) { |
|
| 668 | 668 | |
| 669 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 670 | - $id = esc_attr( $args['id'] ); |
|
| 671 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
| 669 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 670 | + $id = esc_attr($args['id']); |
|
| 671 | + $placeholder = esc_attr($args['placeholder']); |
|
| 672 | 672 | |
| 673 | - if ( ! empty( $args['faux'] ) ) { |
|
| 673 | + if (!empty($args['faux'])) { |
|
| 674 | 674 | $args['readonly'] = true; |
| 675 | 675 | $name = ''; |
| 676 | 676 | } else { |
| 677 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 677 | + $value = wpinv_get_option($args['id'], $value); |
|
| 678 | 678 | $name = "wpinv_settings[$id]"; |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 682 | - $class = esc_attr( $args['class'] ); |
|
| 683 | - $style = esc_attr( $args['style'] ); |
|
| 684 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 681 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
| 682 | + $class = esc_attr($args['class']); |
|
| 683 | + $style = esc_attr($args['style']); |
|
| 684 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
| 685 | 685 | |
| 686 | 686 | $onchange = ''; |
| 687 | - if ( ! empty( $args['onchange'] ) ) { |
|
| 688 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 687 | + if (!empty($args['onchange'])) { |
|
| 688 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -694,11 +694,11 @@ discard block |
||
| 694 | 694 | /** |
| 695 | 695 | * Displays a text input settings callback. |
| 696 | 696 | */ |
| 697 | -function wpinv_text_callback( $args ) { |
|
| 697 | +function wpinv_text_callback($args) { |
|
| 698 | 698 | |
| 699 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 700 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 701 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 699 | + $desc = wp_kses_post($args['desc']); |
|
| 700 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 701 | + $attr = wpinv_settings_attrs_helper($args); |
|
| 702 | 702 | |
| 703 | 703 | ?> |
| 704 | 704 | <label style="width: 100%;"> |
@@ -712,14 +712,14 @@ discard block |
||
| 712 | 712 | /** |
| 713 | 713 | * Displays a number input settings callback. |
| 714 | 714 | */ |
| 715 | -function wpinv_number_callback( $args ) { |
|
| 715 | +function wpinv_number_callback($args) { |
|
| 716 | 716 | |
| 717 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 718 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 719 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 720 | - $max = intval( $args['max'] ); |
|
| 721 | - $min = intval( $args['min'] ); |
|
| 722 | - $step = floatval( $args['step'] ); |
|
| 717 | + $desc = wp_kses_post($args['desc']); |
|
| 718 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 719 | + $attr = wpinv_settings_attrs_helper($args); |
|
| 720 | + $max = intval($args['max']); |
|
| 721 | + $min = intval($args['min']); |
|
| 722 | + $step = floatval($args['step']); |
|
| 723 | 723 | |
| 724 | 724 | ?> |
| 725 | 725 | <label style="width: 100%;"> |
@@ -730,37 +730,37 @@ discard block |
||
| 730 | 730 | |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | -function wpinv_textarea_callback( $args ) { |
|
| 733 | +function wpinv_textarea_callback($args) { |
|
| 734 | 734 | |
| 735 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 736 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 737 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 735 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 736 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 737 | + $value = wpinv_get_option($args['id'], $std); |
|
| 738 | 738 | |
| 739 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 740 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 739 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 740 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 741 | 741 | |
| 742 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 743 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 742 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 743 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 744 | 744 | |
| 745 | 745 | echo $html; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | -function wpinv_password_callback( $args ) { |
|
| 748 | +function wpinv_password_callback($args) { |
|
| 749 | 749 | |
| 750 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 751 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 752 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 750 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 751 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 752 | + $value = wpinv_get_option($args['id'], $std); |
|
| 753 | 753 | |
| 754 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 755 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 756 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 754 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 755 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
| 756 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 757 | 757 | |
| 758 | 758 | echo $html; |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | function wpinv_missing_callback($args) { |
| 762 | 762 | printf( |
| 763 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 763 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 764 | 764 | '<strong>' . $args['id'] . '</strong>' |
| 765 | 765 | ); |
| 766 | 766 | } |
@@ -768,35 +768,35 @@ discard block |
||
| 768 | 768 | /** |
| 769 | 769 | * Displays a number input settings callback. |
| 770 | 770 | */ |
| 771 | -function wpinv_select_callback( $args ) { |
|
| 771 | +function wpinv_select_callback($args) { |
|
| 772 | 772 | |
| 773 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 774 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 775 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 776 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 777 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 778 | - $rand = uniqid( 'random_id' ); |
|
| 773 | + $desc = wp_kses_post($args['desc']); |
|
| 774 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 775 | + $attr = wpinv_settings_attrs_helper($args); |
|
| 776 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 777 | + $value = wpinv_get_option($args['id'], $value); |
|
| 778 | + $rand = uniqid('random_id'); |
|
| 779 | 779 | |
| 780 | 780 | ?> |
| 781 | 781 | <label style="width: 100%;"> |
| 782 | 782 | <select <?php echo $attr; ?>> |
| 783 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
| 784 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
| 785 | - <?php endforeach;?> |
|
| 783 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
| 784 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
| 785 | + <?php endforeach; ?> |
|
| 786 | 786 | </select> |
| 787 | 787 | |
| 788 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
| 789 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a> |
|
| 788 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
| 789 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing') ?></a> |
|
| 790 | 790 | <?php endif; ?> |
| 791 | 791 | |
| 792 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
| 793 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a> |
|
| 792 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
| 793 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing') ?></a> |
|
| 794 | 794 | <div id='<?php echo $rand; ?>' style='display:none;'> |
| 795 | 795 | <div> |
| 796 | - <h3><?php _e( 'Original Content', 'invoicing' ) ?></h3> |
|
| 797 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
| 798 | - <h3><?php _e( 'Current Content', 'invoicing' ) ?></h3> |
|
| 799 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
| 796 | + <h3><?php _e('Original Content', 'invoicing') ?></h3> |
|
| 797 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
| 798 | + <h3><?php _e('Current Content', 'invoicing') ?></h3> |
|
| 799 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
| 800 | 800 | </div> |
| 801 | 801 | </div> |
| 802 | 802 | <?php endif; ?> |
@@ -807,88 +807,88 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | -function wpinv_color_select_callback( $args ) { |
|
| 810 | +function wpinv_color_select_callback($args) { |
|
| 811 | 811 | |
| 812 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 813 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 814 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 812 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 813 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 814 | + $value = wpinv_get_option($args['id'], $std); |
|
| 815 | 815 | |
| 816 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 816 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 817 | 817 | |
| 818 | - foreach ( $args['options'] as $option => $color ) { |
|
| 819 | - $selected = selected( $option, $value, false ); |
|
| 820 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 818 | + foreach ($args['options'] as $option => $color) { |
|
| 819 | + $selected = selected($option, $value, false); |
|
| 820 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | $html .= '</select>'; |
| 824 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 824 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 825 | 825 | |
| 826 | 826 | echo $html; |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | -function wpinv_rich_editor_callback( $args ) { |
|
| 829 | +function wpinv_rich_editor_callback($args) { |
|
| 830 | 830 | global $wp_version; |
| 831 | 831 | |
| 832 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 832 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 833 | 833 | |
| 834 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 835 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 834 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 835 | + $value = wpinv_get_option($args['id'], $std); |
|
| 836 | 836 | |
| 837 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 837 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
| 838 | 838 | $value = $std; |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 841 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 842 | 842 | |
| 843 | 843 | $html = '<div class="getpaid-settings-editor-input">'; |
| 844 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 844 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 845 | 845 | ob_start(); |
| 846 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
| 846 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
| 847 | 847 | $html .= ob_get_clean(); |
| 848 | 848 | } else { |
| 849 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 849 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 852 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 853 | 853 | |
| 854 | 854 | echo $html; |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | -function wpinv_upload_callback( $args ) { |
|
| 857 | +function wpinv_upload_callback($args) { |
|
| 858 | 858 | |
| 859 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 859 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 860 | 860 | |
| 861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 861 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 862 | + $value = wpinv_get_option($args['id'], $std); |
|
| 863 | 863 | |
| 864 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 865 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 866 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 867 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 864 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 865 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 866 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 867 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 868 | 868 | |
| 869 | 869 | echo $html; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | -function wpinv_color_callback( $args ) { |
|
| 872 | +function wpinv_color_callback($args) { |
|
| 873 | 873 | |
| 874 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 875 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 876 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 874 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 875 | + $value = wpinv_get_option($args['id'], $std); |
|
| 876 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 877 | 877 | |
| 878 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
| 879 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 878 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
| 879 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 880 | 880 | |
| 881 | 881 | echo $html; |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | function wpinv_country_states_callback($args) { |
| 885 | 885 | |
| 886 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 887 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 886 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 887 | + $value = wpinv_get_option($args['id'], $std); |
|
| 888 | 888 | |
| 889 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 889 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 890 | 890 | |
| 891 | - if ( isset( $args['placeholder'] ) ) { |
|
| 891 | + if (isset($args['placeholder'])) { |
|
| 892 | 892 | $placeholder = $args['placeholder']; |
| 893 | 893 | } else { |
| 894 | 894 | $placeholder = ''; |
@@ -896,16 +896,16 @@ discard block |
||
| 896 | 896 | |
| 897 | 897 | $states = wpinv_get_country_states(); |
| 898 | 898 | |
| 899 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 900 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 899 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 900 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 901 | 901 | |
| 902 | - foreach ( $states as $option => $name ) { |
|
| 903 | - $selected = selected( $option, $value, false ); |
|
| 904 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 902 | + foreach ($states as $option => $name) { |
|
| 903 | + $selected = selected($option, $value, false); |
|
| 904 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | $html .= '</select>'; |
| 908 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 908 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 909 | 909 | |
| 910 | 910 | echo $html; |
| 911 | 911 | } |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | </tr> |
| 921 | 921 | <tr class="bsui"> |
| 922 | 922 | <td colspan="2" class="p-0"> |
| 923 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
| 923 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
| 924 | 924 | |
| 925 | 925 | <?php |
| 926 | 926 | |
@@ -929,14 +929,14 @@ discard block |
||
| 929 | 929 | /** |
| 930 | 930 | * Displays a tax rate' edit row. |
| 931 | 931 | */ |
| 932 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
| 932 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
| 933 | 933 | ob_start(); |
| 934 | 934 | |
| 935 | - $key = sanitize_key( $key ); |
|
| 936 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 937 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 935 | + $key = sanitize_key($key); |
|
| 936 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
| 937 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
| 938 | 938 | |
| 939 | - if ( $echo ) { |
|
| 939 | + if ($echo) { |
|
| 940 | 940 | echo ob_get_clean(); |
| 941 | 941 | } else { |
| 942 | 942 | return ob_get_clean(); |
@@ -949,134 +949,134 @@ discard block |
||
| 949 | 949 | ob_start(); ?> |
| 950 | 950 | </td><tr> |
| 951 | 951 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 952 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 953 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 952 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 953 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 954 | 954 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 955 | 955 | <thead> |
| 956 | 956 | <tr> |
| 957 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 958 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 959 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 957 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 958 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 959 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 960 | 960 | </tr> |
| 961 | 961 | </thead> |
| 962 | 962 | |
| 963 | 963 | <tbody> |
| 964 | 964 | <tr> |
| 965 | - <td><?php _e( 'Check Pages', 'invoicing' );?></td> |
|
| 965 | + <td><?php _e('Check Pages', 'invoicing'); ?></td> |
|
| 966 | 966 | <td> |
| 967 | - <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
| 967 | + <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
| 968 | 968 | </td> |
| 969 | 969 | <td> |
| 970 | 970 | <a href="<?php |
| 971 | 971 | echo esc_url( |
| 972 | 972 | wp_nonce_url( |
| 973 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 973 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
| 974 | 974 | 'getpaid-nonce', |
| 975 | 975 | 'getpaid-nonce' |
| 976 | 976 | ) |
| 977 | 977 | ); |
| 978 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 978 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 979 | 979 | </td> |
| 980 | 980 | </tr> |
| 981 | 981 | <tr> |
| 982 | - <td><?php _e( 'Create Database Tables', 'invoicing' );?></td> |
|
| 982 | + <td><?php _e('Create Database Tables', 'invoicing'); ?></td> |
|
| 983 | 983 | <td> |
| 984 | - <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
| 984 | + <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
| 985 | 985 | </td> |
| 986 | 986 | <td> |
| 987 | 987 | <a href="<?php |
| 988 | 988 | echo esc_url( |
| 989 | 989 | wp_nonce_url( |
| 990 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 990 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
| 991 | 991 | 'getpaid-nonce', |
| 992 | 992 | 'getpaid-nonce' |
| 993 | 993 | ) |
| 994 | 994 | ); |
| 995 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 995 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 996 | 996 | </td> |
| 997 | 997 | </tr> |
| 998 | 998 | <tr> |
| 999 | - <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td> |
|
| 999 | + <td><?php _e('Migrate old invoices', 'invoicing'); ?></td> |
|
| 1000 | 1000 | <td> |
| 1001 | - <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
| 1001 | + <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
| 1002 | 1002 | </td> |
| 1003 | 1003 | <td> |
| 1004 | 1004 | <a href="<?php |
| 1005 | 1005 | echo esc_url( |
| 1006 | 1006 | wp_nonce_url( |
| 1007 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 1007 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
| 1008 | 1008 | 'getpaid-nonce', |
| 1009 | 1009 | 'getpaid-nonce' |
| 1010 | 1010 | ) |
| 1011 | 1011 | ); |
| 1012 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 1012 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 1013 | 1013 | </td> |
| 1014 | 1014 | </tr> |
| 1015 | 1015 | |
| 1016 | 1016 | <tr> |
| 1017 | - <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td> |
|
| 1017 | + <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td> |
|
| 1018 | 1018 | <td> |
| 1019 | - <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
| 1019 | + <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
| 1020 | 1020 | </td> |
| 1021 | 1021 | <td> |
| 1022 | 1022 | <a href="<?php |
| 1023 | 1023 | echo esc_url( |
| 1024 | 1024 | wp_nonce_url( |
| 1025 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 1025 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
| 1026 | 1026 | 'getpaid-nonce', |
| 1027 | 1027 | 'getpaid-nonce' |
| 1028 | 1028 | ) |
| 1029 | 1029 | ); |
| 1030 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
| 1030 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 1031 | 1031 | </td> |
| 1032 | 1032 | </tr> |
| 1033 | 1033 | |
| 1034 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1034 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1035 | 1035 | </tbody> |
| 1036 | 1036 | </table> |
| 1037 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1037 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1038 | 1038 | <?php |
| 1039 | 1039 | echo ob_get_clean(); |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | |
| 1043 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1044 | - echo wp_kses_post( $args['desc'] ); |
|
| 1043 | +function wpinv_descriptive_text_callback($args) { |
|
| 1044 | + echo wp_kses_post($args['desc']); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | -function wpinv_raw_html_callback( $args ) { |
|
| 1047 | +function wpinv_raw_html_callback($args) { |
|
| 1048 | 1048 | echo $args['desc']; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | -function wpinv_hook_callback( $args ) { |
|
| 1052 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1051 | +function wpinv_hook_callback($args) { |
|
| 1052 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | function wpinv_set_settings_cap() { |
| 1056 | 1056 | return wpinv_get_capability(); |
| 1057 | 1057 | } |
| 1058 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1058 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
| 1059 | 1059 | |
| 1060 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
| 1060 | +function wpinv_settings_sanitize_input($value, $key) { |
|
| 1061 | 1061 | |
| 1062 | - if ( $key == 'tax_rate' ) { |
|
| 1063 | - $value = wpinv_sanitize_amount( $value ); |
|
| 1064 | - $value = absint( min( $value, 99 ) ); |
|
| 1062 | + if ($key == 'tax_rate') { |
|
| 1063 | + $value = wpinv_sanitize_amount($value); |
|
| 1064 | + $value = absint(min($value, 99)); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | return $value; |
| 1068 | 1068 | } |
| 1069 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
| 1069 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
| 1070 | 1070 | |
| 1071 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
| 1072 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1073 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1071 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
| 1072 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1073 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1074 | 1074 | |
| 1075 | - if ( $old != $new ) { |
|
| 1076 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
| 1075 | + if ($old != $new) { |
|
| 1076 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | } |
| 1079 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
| 1079 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
| 1080 | 1080 | |
| 1081 | 1081 | /** |
| 1082 | 1082 | * Returns the merge tags help text. |
@@ -1085,16 +1085,16 @@ discard block |
||
| 1085 | 1085 | * |
| 1086 | 1086 | * @return string |
| 1087 | 1087 | */ |
| 1088 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
| 1088 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
| 1089 | 1089 | |
| 1090 | 1090 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
| 1091 | 1091 | $link = sprintf( |
| 1092 | 1092 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
| 1093 | 1093 | $url, |
| 1094 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1094 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
| 1095 | 1095 | ); |
| 1096 | 1096 | |
| 1097 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1097 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
| 1098 | 1098 | |
| 1099 | 1099 | return "$description $link"; |
| 1100 | 1100 | |
@@ -10,66 +10,66 @@ 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_line_item', $invoice, $item ); ?> |
|
| 17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
| 18 | 18 | |
| 19 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
| 19 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
| 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 line item column. |
| 28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
| 28 | + do_action("getpaid_email_line_item_before_$column", $item, $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( $item->get_name() ) . '</div>'; |
|
| 34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
| 35 | 35 | |
| 36 | 36 | // And an optional description. |
| 37 | 37 | $description = $item->get_description(); |
| 38 | 38 | |
| 39 | - if ( ! empty( $description ) ) { |
|
| 40 | - $description = wp_kses_post( $description ); |
|
| 39 | + if (!empty($description)) { |
|
| 40 | + $description = wp_kses_post($description); |
|
| 41 | 41 | echo "<p class='small'>$description</p>"; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // Item price. |
| 47 | - if ( 'price' == $column ) { |
|
| 47 | + if ('price' == $column) { |
|
| 48 | 48 | |
| 49 | 49 | // Display the item price (or recurring price if this is a renewal invoice) |
| 50 | 50 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
| 51 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
| 51 | + echo wpinv_price($price, $invoice->get_currency()); |
|
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Item quantity. |
| 56 | - if ( 'quantity' == $column ) { |
|
| 56 | + if ('quantity' == $column) { |
|
| 57 | 57 | echo (float) $item->get_quantity(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Tax rate. |
| 61 | - if ( 'tax_rate' == $column ) { |
|
| 62 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
| 61 | + if ('tax_rate' == $column) { |
|
| 62 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Item sub total. |
| 66 | - if ( 'subtotal' == $column ) { |
|
| 66 | + if ('subtotal' == $column) { |
|
| 67 | 67 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
| 68 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
| 68 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Fires when printing a line item column. |
| 72 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
| 72 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
| 73 | 73 | |
| 74 | 74 | ?> |
| 75 | 75 | |
@@ -79,4 +79,4 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | </tr> |
| 81 | 81 | |
| 82 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
| 82 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
|