@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | - exit; |
|
| 18 | + exit; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) { |
| 22 | - // include the class if needed |
|
| 23 | - include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" ); |
|
| 22 | + // include the class if needed |
|
| 23 | + include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -36,6 +36,6 @@ discard block |
||
| 36 | 36 | //}); |
| 37 | 37 | |
| 38 | 38 | AyeCode_Deactivation_Survey::instance(array( |
| 39 | - 'slug' => 'ayecode-deactivation-survey-testing', |
|
| 40 | - 'version' => '1.0.0' |
|
| 39 | + 'slug' => 'ayecode-deactivation-survey-testing', |
|
| 40 | + 'version' => '1.0.0' |
|
| 41 | 41 | )); |
| 42 | 42 | \ No newline at end of file |
@@ -14,13 +14,13 @@ |
||
| 14 | 14 | * Tested up to: 5.8 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 17 | +if (!defined('ABSPATH')) { |
|
| 18 | 18 | exit; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) { |
|
| 21 | +if (!class_exists('AyeCode_Deactivation_Survey')) { |
|
| 22 | 22 | // include the class if needed |
| 23 | - include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" ); |
|
| 23 | + include_once(dirname(__FILE__) . "/wp-deactivation-survey.php"); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -20,228 +20,228 @@ 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 | - $installed = get_option( 'gepaid_installed_on' ); |
|
| 52 | - |
|
| 53 | - if ( empty( $installed ) ) { |
|
| 54 | - update_option( 'gepaid_installed_on', time() ); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if ( method_exists( $this, $method ) ) { |
|
| 58 | - $this->$method(); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Do a fresh install. |
|
| 65 | - * |
|
| 66 | - */ |
|
| 67 | - public function upgrade_from_0() { |
|
| 68 | - $this->create_subscriptions_table(); |
|
| 69 | - $this->create_invoices_table(); |
|
| 70 | - $this->create_invoice_items_table(); |
|
| 71 | - |
|
| 72 | - // Save default tax rates. |
|
| 73 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Upgrade to 0.0.5 |
|
| 78 | - * |
|
| 79 | - */ |
|
| 80 | - public function upgrade_from_004() { |
|
| 81 | - global $wpdb; |
|
| 82 | - |
|
| 83 | - // Invoices. |
|
| 84 | - $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' )" ); |
|
| 85 | - if ( ! empty( $results ) ) { |
|
| 86 | - $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' )" ); |
|
| 87 | - |
|
| 88 | - // Clean post cache |
|
| 89 | - foreach ( $results as $row ) { |
|
| 90 | - clean_post_cache( $row->ID ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // Item meta key changes |
|
| 96 | - $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' )"; |
|
| 97 | - $results = $wpdb->get_results( $query ); |
|
| 98 | - |
|
| 99 | - if ( ! empty( $results ) ) { |
|
| 100 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
| 101 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
| 102 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
| 103 | - |
|
| 104 | - foreach ( $results as $row ) { |
|
| 105 | - clean_post_cache( $row->post_id ); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $this->upgrade_from_102(); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Upgrade to 1.0.3 |
|
| 115 | - * |
|
| 116 | - */ |
|
| 117 | - public function upgrade_from_102() { |
|
| 118 | - $this->create_subscriptions_table(); |
|
| 119 | - $this->upgrade_from_118(); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Upgrade to version 2.0.0. |
|
| 124 | - * |
|
| 125 | - */ |
|
| 126 | - public function upgrade_from_118() { |
|
| 127 | - $this->create_invoices_table(); |
|
| 128 | - $this->create_invoice_items_table(); |
|
| 129 | - $this->migrate_old_invoices(); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Upgrade to version 2.0.8. |
|
| 134 | - * |
|
| 135 | - */ |
|
| 136 | - public function upgrade_from_207() { |
|
| 137 | - global $wpdb; |
|
| 138 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Give administrators the capability to manage GetPaid. |
|
| 143 | - * |
|
| 144 | - */ |
|
| 145 | - public function add_capabilities() { |
|
| 146 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Retreives GetPaid pages. |
|
| 151 | - * |
|
| 152 | - */ |
|
| 153 | - public static function get_pages() { |
|
| 154 | - |
|
| 155 | - return apply_filters( |
|
| 156 | - 'wpinv_create_pages', |
|
| 157 | - array( |
|
| 158 | - |
|
| 159 | - // Checkout page. |
|
| 160 | - 'checkout_page' => array( |
|
| 161 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
| 162 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
| 163 | - '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 | + $installed = get_option( 'gepaid_installed_on' ); |
|
| 52 | + |
|
| 53 | + if ( empty( $installed ) ) { |
|
| 54 | + update_option( 'gepaid_installed_on', time() ); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if ( method_exists( $this, $method ) ) { |
|
| 58 | + $this->$method(); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Do a fresh install. |
|
| 65 | + * |
|
| 66 | + */ |
|
| 67 | + public function upgrade_from_0() { |
|
| 68 | + $this->create_subscriptions_table(); |
|
| 69 | + $this->create_invoices_table(); |
|
| 70 | + $this->create_invoice_items_table(); |
|
| 71 | + |
|
| 72 | + // Save default tax rates. |
|
| 73 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Upgrade to 0.0.5 |
|
| 78 | + * |
|
| 79 | + */ |
|
| 80 | + public function upgrade_from_004() { |
|
| 81 | + global $wpdb; |
|
| 82 | + |
|
| 83 | + // Invoices. |
|
| 84 | + $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' )" ); |
|
| 85 | + if ( ! empty( $results ) ) { |
|
| 86 | + $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' )" ); |
|
| 87 | + |
|
| 88 | + // Clean post cache |
|
| 89 | + foreach ( $results as $row ) { |
|
| 90 | + clean_post_cache( $row->ID ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // Item meta key changes |
|
| 96 | + $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' )"; |
|
| 97 | + $results = $wpdb->get_results( $query ); |
|
| 98 | + |
|
| 99 | + if ( ! empty( $results ) ) { |
|
| 100 | + $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
| 101 | + $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
| 102 | + $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
| 103 | + |
|
| 104 | + foreach ( $results as $row ) { |
|
| 105 | + clean_post_cache( $row->post_id ); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $this->upgrade_from_102(); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Upgrade to 1.0.3 |
|
| 115 | + * |
|
| 116 | + */ |
|
| 117 | + public function upgrade_from_102() { |
|
| 118 | + $this->create_subscriptions_table(); |
|
| 119 | + $this->upgrade_from_118(); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Upgrade to version 2.0.0. |
|
| 124 | + * |
|
| 125 | + */ |
|
| 126 | + public function upgrade_from_118() { |
|
| 127 | + $this->create_invoices_table(); |
|
| 128 | + $this->create_invoice_items_table(); |
|
| 129 | + $this->migrate_old_invoices(); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Upgrade to version 2.0.8. |
|
| 134 | + * |
|
| 135 | + */ |
|
| 136 | + public function upgrade_from_207() { |
|
| 137 | + global $wpdb; |
|
| 138 | + $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Give administrators the capability to manage GetPaid. |
|
| 143 | + * |
|
| 144 | + */ |
|
| 145 | + public function add_capabilities() { |
|
| 146 | + $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Retreives GetPaid pages. |
|
| 151 | + * |
|
| 152 | + */ |
|
| 153 | + public static function get_pages() { |
|
| 154 | + |
|
| 155 | + return apply_filters( |
|
| 156 | + 'wpinv_create_pages', |
|
| 157 | + array( |
|
| 158 | + |
|
| 159 | + // Checkout page. |
|
| 160 | + 'checkout_page' => array( |
|
| 161 | + 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
| 162 | + 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
| 163 | + 'content' => ' |
|
| 164 | 164 | <!-- wp:shortcode --> |
| 165 | 165 | [wpinv_checkout] |
| 166 | 166 | <!-- /wp:shortcode --> |
| 167 | 167 | ', |
| 168 | - 'parent' => '', |
|
| 169 | - ), |
|
| 170 | - |
|
| 171 | - // Invoice history page. |
|
| 172 | - 'invoice_history_page' => array( |
|
| 173 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
| 174 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
| 175 | - 'content' => ' |
|
| 168 | + 'parent' => '', |
|
| 169 | + ), |
|
| 170 | + |
|
| 171 | + // Invoice history page. |
|
| 172 | + 'invoice_history_page' => array( |
|
| 173 | + 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
| 174 | + 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
| 175 | + 'content' => ' |
|
| 176 | 176 | <!-- wp:shortcode --> |
| 177 | 177 | [wpinv_history] |
| 178 | 178 | <!-- /wp:shortcode --> |
| 179 | 179 | ', |
| 180 | - 'parent' => '', |
|
| 181 | - ), |
|
| 182 | - |
|
| 183 | - // Success page content. |
|
| 184 | - 'success_page' => array( |
|
| 185 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
| 186 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
| 187 | - 'content' => ' |
|
| 180 | + 'parent' => '', |
|
| 181 | + ), |
|
| 182 | + |
|
| 183 | + // Success page content. |
|
| 184 | + 'success_page' => array( |
|
| 185 | + 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
| 186 | + 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
| 187 | + 'content' => ' |
|
| 188 | 188 | <!-- wp:shortcode --> |
| 189 | 189 | [wpinv_receipt] |
| 190 | 190 | <!-- /wp:shortcode --> |
| 191 | 191 | ', |
| 192 | - 'parent' => 'gp-checkout', |
|
| 193 | - ), |
|
| 194 | - |
|
| 195 | - // Failure page content. |
|
| 196 | - 'failure_page' => array( |
|
| 197 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
| 198 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
| 199 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 200 | - 'parent' => 'gp-checkout', |
|
| 201 | - ), |
|
| 202 | - |
|
| 203 | - // Subscriptions history page. |
|
| 204 | - 'invoice_subscription_page' => array( |
|
| 205 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
| 206 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
| 207 | - 'content' => ' |
|
| 192 | + 'parent' => 'gp-checkout', |
|
| 193 | + ), |
|
| 194 | + |
|
| 195 | + // Failure page content. |
|
| 196 | + 'failure_page' => array( |
|
| 197 | + 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
| 198 | + 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
| 199 | + 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 200 | + 'parent' => 'gp-checkout', |
|
| 201 | + ), |
|
| 202 | + |
|
| 203 | + // Subscriptions history page. |
|
| 204 | + 'invoice_subscription_page' => array( |
|
| 205 | + 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
| 206 | + 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
| 207 | + 'content' => ' |
|
| 208 | 208 | <!-- wp:shortcode --> |
| 209 | 209 | [wpinv_subscriptions] |
| 210 | 210 | <!-- /wp:shortcode --> |
| 211 | 211 | ', |
| 212 | - 'parent' => '', |
|
| 213 | - ), |
|
| 212 | + 'parent' => '', |
|
| 213 | + ), |
|
| 214 | 214 | |
| 215 | - ) |
|
| 216 | - ); |
|
| 215 | + ) |
|
| 216 | + ); |
|
| 217 | 217 | |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * Re-create GetPaid pages. |
|
| 222 | - * |
|
| 223 | - */ |
|
| 224 | - public function create_pages() { |
|
| 220 | + /** |
|
| 221 | + * Re-create GetPaid pages. |
|
| 222 | + * |
|
| 223 | + */ |
|
| 224 | + public function create_pages() { |
|
| 225 | 225 | |
| 226 | - foreach ( self::get_pages() as $key => $page ) { |
|
| 227 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
| 228 | - } |
|
| 226 | + foreach ( self::get_pages() as $key => $page ) { |
|
| 227 | + wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - } |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - /** |
|
| 233 | - * Create subscriptions table. |
|
| 234 | - * |
|
| 235 | - */ |
|
| 236 | - public function create_subscriptions_table() { |
|
| 232 | + /** |
|
| 233 | + * Create subscriptions table. |
|
| 234 | + * |
|
| 235 | + */ |
|
| 236 | + public function create_subscriptions_table() { |
|
| 237 | 237 | |
| 238 | - global $wpdb; |
|
| 238 | + global $wpdb; |
|
| 239 | 239 | |
| 240 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 240 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 241 | 241 | |
| 242 | - // Create tables. |
|
| 243 | - $charset_collate = $wpdb->get_charset_collate(); |
|
| 244 | - $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions ( |
|
| 242 | + // Create tables. |
|
| 243 | + $charset_collate = $wpdb->get_charset_collate(); |
|
| 244 | + $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions ( |
|
| 245 | 245 | id bigint(20) unsigned NOT NULL auto_increment, |
| 246 | 246 | customer_id bigint(20) NOT NULL, |
| 247 | 247 | frequency int(11) NOT NULL DEFAULT '1', |
@@ -264,22 +264,22 @@ discard block |
||
| 264 | 264 | KEY customer_and_status (customer_id, status) |
| 265 | 265 | ) $charset_collate;"; |
| 266 | 266 | |
| 267 | - dbDelta( $sql ); |
|
| 267 | + dbDelta( $sql ); |
|
| 268 | 268 | |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - /** |
|
| 272 | - * Create invoices table. |
|
| 273 | - * |
|
| 274 | - */ |
|
| 275 | - public function create_invoices_table() { |
|
| 276 | - global $wpdb; |
|
| 271 | + /** |
|
| 272 | + * Create invoices table. |
|
| 273 | + * |
|
| 274 | + */ |
|
| 275 | + public function create_invoices_table() { |
|
| 276 | + global $wpdb; |
|
| 277 | 277 | |
| 278 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 278 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 279 | 279 | |
| 280 | - // Create tables. |
|
| 281 | - $charset_collate = $wpdb->get_charset_collate(); |
|
| 282 | - $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices ( |
|
| 280 | + // Create tables. |
|
| 281 | + $charset_collate = $wpdb->get_charset_collate(); |
|
| 282 | + $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices ( |
|
| 283 | 283 | post_id BIGINT(20) NOT NULL, |
| 284 | 284 | `number` VARCHAR(100), |
| 285 | 285 | `key` VARCHAR(100), |
@@ -315,22 +315,22 @@ discard block |
||
| 315 | 315 | KEY `key` (`key`) |
| 316 | 316 | ) $charset_collate;"; |
| 317 | 317 | |
| 318 | - dbDelta( $sql ); |
|
| 318 | + dbDelta( $sql ); |
|
| 319 | 319 | |
| 320 | - } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * Create invoice items table. |
|
| 324 | - * |
|
| 325 | - */ |
|
| 326 | - public function create_invoice_items_table() { |
|
| 327 | - global $wpdb; |
|
| 322 | + /** |
|
| 323 | + * Create invoice items table. |
|
| 324 | + * |
|
| 325 | + */ |
|
| 326 | + public function create_invoice_items_table() { |
|
| 327 | + global $wpdb; |
|
| 328 | 328 | |
| 329 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 329 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 330 | 330 | |
| 331 | - // Create tables. |
|
| 332 | - $charset_collate = $wpdb->get_charset_collate(); |
|
| 333 | - $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items ( |
|
| 331 | + // Create tables. |
|
| 332 | + $charset_collate = $wpdb->get_charset_collate(); |
|
| 333 | + $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items ( |
|
| 334 | 334 | ID BIGINT(20) NOT NULL AUTO_INCREMENT, |
| 335 | 335 | post_id BIGINT(20) NOT NULL, |
| 336 | 336 | item_id BIGINT(20) NOT NULL, |
@@ -352,159 +352,159 @@ discard block |
||
| 352 | 352 | KEY post_id (post_id) |
| 353 | 353 | ) $charset_collate;"; |
| 354 | 354 | |
| 355 | - dbDelta( $sql ); |
|
| 356 | - |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * Migrates old invoices to new invoices. |
|
| 361 | - * |
|
| 362 | - */ |
|
| 363 | - public function migrate_old_invoices() { |
|
| 364 | - global $wpdb; |
|
| 365 | - |
|
| 366 | - $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 367 | - $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
| 368 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
| 369 | - $invoices = array_unique( |
|
| 370 | - get_posts( |
|
| 371 | - array( |
|
| 372 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
| 373 | - 'posts_per_page' => -1, |
|
| 374 | - 'fields' => 'ids', |
|
| 375 | - 'post_status' => array_keys( get_post_stati() ), |
|
| 376 | - 'exclude' => (array) $migrated, |
|
| 377 | - ) |
|
| 378 | - ) |
|
| 379 | - ); |
|
| 380 | - |
|
| 381 | - // Abort if we do not have any invoices. |
|
| 382 | - if ( empty( $invoices ) ) { |
|
| 383 | - return; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
| 387 | - |
|
| 388 | - $invoice_rows = array(); |
|
| 389 | - foreach ( $invoices as $invoice ) { |
|
| 390 | - |
|
| 391 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
| 392 | - |
|
| 393 | - if ( empty( $invoice->ID ) ) { |
|
| 394 | - return; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - $fields = array ( |
|
| 398 | - 'post_id' => $invoice->ID, |
|
| 399 | - 'number' => $invoice->get_number(), |
|
| 400 | - 'key' => $invoice->get_key(), |
|
| 401 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
| 402 | - 'mode' => $invoice->mode, |
|
| 403 | - 'user_ip' => $invoice->get_ip(), |
|
| 404 | - 'first_name' => $invoice->get_first_name(), |
|
| 405 | - 'last_name' => $invoice->get_last_name(), |
|
| 406 | - 'address' => $invoice->get_address(), |
|
| 407 | - 'city' => $invoice->city, |
|
| 408 | - 'state' => $invoice->state, |
|
| 409 | - 'country' => $invoice->country, |
|
| 410 | - 'zip' => $invoice->zip, |
|
| 411 | - 'adddress_confirmed' => (int) $invoice->adddress_confirmed, |
|
| 412 | - 'gateway' => $invoice->get_gateway(), |
|
| 413 | - 'transaction_id' => $invoice->get_transaction_id(), |
|
| 414 | - 'currency' => $invoice->get_currency(), |
|
| 415 | - 'subtotal' => $invoice->get_subtotal(), |
|
| 416 | - 'tax' => $invoice->get_tax(), |
|
| 417 | - 'fees_total' => $invoice->get_fees_total(), |
|
| 418 | - 'total' => $invoice->get_total(), |
|
| 419 | - 'discount' => $invoice->get_discount(), |
|
| 420 | - 'discount_code' => $invoice->get_discount_code(), |
|
| 421 | - 'disable_taxes' => $invoice->disable_taxes, |
|
| 422 | - 'due_date' => $invoice->get_due_date(), |
|
| 423 | - 'completed_date' => $invoice->get_completed_date(), |
|
| 424 | - 'company' => $invoice->company, |
|
| 425 | - 'vat_number' => $invoice->vat_number, |
|
| 426 | - 'vat_rate' => $invoice->vat_rate, |
|
| 427 | - 'custom_meta' => $invoice->payment_meta |
|
| 428 | - ); |
|
| 429 | - |
|
| 430 | - foreach ( $fields as $key => $val ) { |
|
| 431 | - if ( is_null( $val ) ) { |
|
| 432 | - $val = ''; |
|
| 433 | - } |
|
| 434 | - $val = maybe_serialize( $val ); |
|
| 435 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - $fields = implode( ', ', $fields ); |
|
| 439 | - $invoice_rows[] = "($fields)"; |
|
| 440 | - |
|
| 441 | - $item_rows = array(); |
|
| 442 | - $item_columns = array(); |
|
| 443 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
| 444 | - $fields = array( |
|
| 445 | - 'post_id' => $invoice->ID, |
|
| 446 | - 'item_id' => $details['id'], |
|
| 447 | - 'item_name' => $details['name'], |
|
| 448 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
| 449 | - 'vat_rate' => $details['vat_rate'], |
|
| 450 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
| 451 | - 'tax' => $details['tax'], |
|
| 452 | - 'item_price' => $details['item_price'], |
|
| 453 | - 'custom_price' => $details['custom_price'], |
|
| 454 | - 'quantity' => $details['quantity'], |
|
| 455 | - 'discount' => $details['discount'], |
|
| 456 | - 'subtotal' => $details['subtotal'], |
|
| 457 | - 'price' => $details['price'], |
|
| 458 | - 'meta' => $details['meta'], |
|
| 459 | - 'fees' => $details['fees'], |
|
| 460 | - ); |
|
| 461 | - |
|
| 462 | - $item_columns = array_keys ( $fields ); |
|
| 463 | - |
|
| 464 | - foreach ( $fields as $key => $val ) { |
|
| 465 | - if ( is_null( $val ) ) { |
|
| 466 | - $val = ''; |
|
| 467 | - } |
|
| 468 | - $val = maybe_serialize( $val ); |
|
| 469 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - $fields = implode( ', ', $fields ); |
|
| 473 | - $item_rows[] = "($fields)"; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - $item_rows = implode( ', ', $item_rows ); |
|
| 477 | - $item_columns = implode( ', ', $item_columns ); |
|
| 478 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - if ( empty( $invoice_rows ) ) { |
|
| 482 | - return; |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
| 486 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
| 487 | - |
|
| 488 | - } |
|
| 489 | - |
|
| 490 | - /** |
|
| 491 | - * Migrates old invoices to new invoices. |
|
| 492 | - * |
|
| 493 | - */ |
|
| 494 | - public static function rename_gateways_label() { |
|
| 495 | - global $wpdb; |
|
| 496 | - |
|
| 497 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
| 498 | - |
|
| 499 | - $wpdb->update( |
|
| 500 | - $wpdb->prefix . 'getpaid_invoices', |
|
| 501 | - array( 'gateway' => $gateway ), |
|
| 502 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
| 503 | - '%s', |
|
| 504 | - '%s' |
|
| 505 | - ); |
|
| 506 | - |
|
| 507 | - } |
|
| 508 | - } |
|
| 355 | + dbDelta( $sql ); |
|
| 356 | + |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * Migrates old invoices to new invoices. |
|
| 361 | + * |
|
| 362 | + */ |
|
| 363 | + public function migrate_old_invoices() { |
|
| 364 | + global $wpdb; |
|
| 365 | + |
|
| 366 | + $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 367 | + $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
| 368 | + $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
| 369 | + $invoices = array_unique( |
|
| 370 | + get_posts( |
|
| 371 | + array( |
|
| 372 | + 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
| 373 | + 'posts_per_page' => -1, |
|
| 374 | + 'fields' => 'ids', |
|
| 375 | + 'post_status' => array_keys( get_post_stati() ), |
|
| 376 | + 'exclude' => (array) $migrated, |
|
| 377 | + ) |
|
| 378 | + ) |
|
| 379 | + ); |
|
| 380 | + |
|
| 381 | + // Abort if we do not have any invoices. |
|
| 382 | + if ( empty( $invoices ) ) { |
|
| 383 | + return; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
| 387 | + |
|
| 388 | + $invoice_rows = array(); |
|
| 389 | + foreach ( $invoices as $invoice ) { |
|
| 390 | + |
|
| 391 | + $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
| 392 | + |
|
| 393 | + if ( empty( $invoice->ID ) ) { |
|
| 394 | + return; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + $fields = array ( |
|
| 398 | + 'post_id' => $invoice->ID, |
|
| 399 | + 'number' => $invoice->get_number(), |
|
| 400 | + 'key' => $invoice->get_key(), |
|
| 401 | + 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
| 402 | + 'mode' => $invoice->mode, |
|
| 403 | + 'user_ip' => $invoice->get_ip(), |
|
| 404 | + 'first_name' => $invoice->get_first_name(), |
|
| 405 | + 'last_name' => $invoice->get_last_name(), |
|
| 406 | + 'address' => $invoice->get_address(), |
|
| 407 | + 'city' => $invoice->city, |
|
| 408 | + 'state' => $invoice->state, |
|
| 409 | + 'country' => $invoice->country, |
|
| 410 | + 'zip' => $invoice->zip, |
|
| 411 | + 'adddress_confirmed' => (int) $invoice->adddress_confirmed, |
|
| 412 | + 'gateway' => $invoice->get_gateway(), |
|
| 413 | + 'transaction_id' => $invoice->get_transaction_id(), |
|
| 414 | + 'currency' => $invoice->get_currency(), |
|
| 415 | + 'subtotal' => $invoice->get_subtotal(), |
|
| 416 | + 'tax' => $invoice->get_tax(), |
|
| 417 | + 'fees_total' => $invoice->get_fees_total(), |
|
| 418 | + 'total' => $invoice->get_total(), |
|
| 419 | + 'discount' => $invoice->get_discount(), |
|
| 420 | + 'discount_code' => $invoice->get_discount_code(), |
|
| 421 | + 'disable_taxes' => $invoice->disable_taxes, |
|
| 422 | + 'due_date' => $invoice->get_due_date(), |
|
| 423 | + 'completed_date' => $invoice->get_completed_date(), |
|
| 424 | + 'company' => $invoice->company, |
|
| 425 | + 'vat_number' => $invoice->vat_number, |
|
| 426 | + 'vat_rate' => $invoice->vat_rate, |
|
| 427 | + 'custom_meta' => $invoice->payment_meta |
|
| 428 | + ); |
|
| 429 | + |
|
| 430 | + foreach ( $fields as $key => $val ) { |
|
| 431 | + if ( is_null( $val ) ) { |
|
| 432 | + $val = ''; |
|
| 433 | + } |
|
| 434 | + $val = maybe_serialize( $val ); |
|
| 435 | + $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + $fields = implode( ', ', $fields ); |
|
| 439 | + $invoice_rows[] = "($fields)"; |
|
| 440 | + |
|
| 441 | + $item_rows = array(); |
|
| 442 | + $item_columns = array(); |
|
| 443 | + foreach ( $invoice->get_cart_details() as $details ) { |
|
| 444 | + $fields = array( |
|
| 445 | + 'post_id' => $invoice->ID, |
|
| 446 | + 'item_id' => $details['id'], |
|
| 447 | + 'item_name' => $details['name'], |
|
| 448 | + 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
| 449 | + 'vat_rate' => $details['vat_rate'], |
|
| 450 | + 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
| 451 | + 'tax' => $details['tax'], |
|
| 452 | + 'item_price' => $details['item_price'], |
|
| 453 | + 'custom_price' => $details['custom_price'], |
|
| 454 | + 'quantity' => $details['quantity'], |
|
| 455 | + 'discount' => $details['discount'], |
|
| 456 | + 'subtotal' => $details['subtotal'], |
|
| 457 | + 'price' => $details['price'], |
|
| 458 | + 'meta' => $details['meta'], |
|
| 459 | + 'fees' => $details['fees'], |
|
| 460 | + ); |
|
| 461 | + |
|
| 462 | + $item_columns = array_keys ( $fields ); |
|
| 463 | + |
|
| 464 | + foreach ( $fields as $key => $val ) { |
|
| 465 | + if ( is_null( $val ) ) { |
|
| 466 | + $val = ''; |
|
| 467 | + } |
|
| 468 | + $val = maybe_serialize( $val ); |
|
| 469 | + $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + $fields = implode( ', ', $fields ); |
|
| 473 | + $item_rows[] = "($fields)"; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + $item_rows = implode( ', ', $item_rows ); |
|
| 477 | + $item_columns = implode( ', ', $item_columns ); |
|
| 478 | + $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + if ( empty( $invoice_rows ) ) { |
|
| 482 | + return; |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + $invoice_rows = implode( ', ', $invoice_rows ); |
|
| 486 | + $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
| 487 | + |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + /** |
|
| 491 | + * Migrates old invoices to new invoices. |
|
| 492 | + * |
|
| 493 | + */ |
|
| 494 | + public static function rename_gateways_label() { |
|
| 495 | + global $wpdb; |
|
| 496 | + |
|
| 497 | + foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
| 498 | + |
|
| 499 | + $wpdb->update( |
|
| 500 | + $wpdb->prefix . 'getpaid_invoices', |
|
| 501 | + array( 'gateway' => $gateway ), |
|
| 502 | + array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
| 503 | + '%s', |
|
| 504 | + '%s' |
|
| 505 | + ); |
|
| 506 | + |
|
| 507 | + } |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | 510 | } |
@@ -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,13 +48,13 @@ discard block |
||
| 48 | 48 | // Create any missing database tables. |
| 49 | 49 | $method = "upgrade_from_$upgrade_from"; |
| 50 | 50 | |
| 51 | - $installed = get_option( 'gepaid_installed_on' ); |
|
| 51 | + $installed = get_option('gepaid_installed_on'); |
|
| 52 | 52 | |
| 53 | - if ( empty( $installed ) ) { |
|
| 54 | - update_option( 'gepaid_installed_on', time() ); |
|
| 53 | + if (empty($installed)) { |
|
| 54 | + update_option('gepaid_installed_on', time()); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if ( method_exists( $this, $method ) ) { |
|
| 57 | + if (method_exists($this, $method)) { |
|
| 58 | 58 | $this->$method(); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $this->create_invoice_items_table(); |
| 71 | 71 | |
| 72 | 72 | // Save default tax rates. |
| 73 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
| 73 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -81,28 +81,28 @@ discard block |
||
| 81 | 81 | global $wpdb; |
| 82 | 82 | |
| 83 | 83 | // Invoices. |
| 84 | - $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' )" ); |
|
| 85 | - if ( ! empty( $results ) ) { |
|
| 86 | - $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' )" ); |
|
| 84 | + $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' )"); |
|
| 85 | + if (!empty($results)) { |
|
| 86 | + $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' )"); |
|
| 87 | 87 | |
| 88 | 88 | // Clean post cache |
| 89 | - foreach ( $results as $row ) { |
|
| 90 | - clean_post_cache( $row->ID ); |
|
| 89 | + foreach ($results as $row) { |
|
| 90 | + clean_post_cache($row->ID); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Item meta key changes |
| 96 | 96 | $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' )"; |
| 97 | - $results = $wpdb->get_results( $query ); |
|
| 97 | + $results = $wpdb->get_results($query); |
|
| 98 | 98 | |
| 99 | - if ( ! empty( $results ) ) { |
|
| 100 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
| 101 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
| 102 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
| 99 | + if (!empty($results)) { |
|
| 100 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
| 101 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
| 102 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
| 103 | 103 | |
| 104 | - foreach ( $results as $row ) { |
|
| 105 | - clean_post_cache( $row->post_id ); |
|
| 104 | + foreach ($results as $row) { |
|
| 105 | + clean_post_cache($row->post_id); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function upgrade_from_207() { |
| 137 | 137 | global $wpdb; |
| 138 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
| 138 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);"); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | */ |
| 145 | 145 | public function add_capabilities() { |
| 146 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
| 146 | + $GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing'); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | // Checkout page. |
| 160 | 160 | 'checkout_page' => array( |
| 161 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
| 162 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
| 161 | + 'name' => _x('gp-checkout', 'Page slug', 'invoicing'), |
|
| 162 | + 'title' => _x('Checkout', 'Page title', 'invoicing'), |
|
| 163 | 163 | 'content' => ' |
| 164 | 164 | <!-- wp:shortcode --> |
| 165 | 165 | [wpinv_checkout] |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | // Invoice history page. |
| 172 | 172 | 'invoice_history_page' => array( |
| 173 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
| 174 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
| 173 | + 'name' => _x('gp-invoices', 'Page slug', 'invoicing'), |
|
| 174 | + 'title' => _x('My Invoices', 'Page title', 'invoicing'), |
|
| 175 | 175 | 'content' => ' |
| 176 | 176 | <!-- wp:shortcode --> |
| 177 | 177 | [wpinv_history] |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | // Success page content. |
| 184 | 184 | 'success_page' => array( |
| 185 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
| 186 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
| 185 | + 'name' => _x('gp-receipt', 'Page slug', 'invoicing'), |
|
| 186 | + 'title' => _x('Payment Confirmation', 'Page title', 'invoicing'), |
|
| 187 | 187 | 'content' => ' |
| 188 | 188 | <!-- wp:shortcode --> |
| 189 | 189 | [wpinv_receipt] |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | // Failure page content. |
| 196 | 196 | 'failure_page' => array( |
| 197 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
| 198 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
| 199 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
| 197 | + 'name' => _x('gp-transaction-failed', 'Page slug', 'invoicing'), |
|
| 198 | + 'title' => _x('Transaction Failed', 'Page title', 'invoicing'), |
|
| 199 | + 'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
| 200 | 200 | 'parent' => 'gp-checkout', |
| 201 | 201 | ), |
| 202 | 202 | |
| 203 | 203 | // Subscriptions history page. |
| 204 | 204 | 'invoice_subscription_page' => array( |
| 205 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
| 206 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
| 205 | + 'name' => _x('gp-subscriptions', 'Page slug', 'invoicing'), |
|
| 206 | + 'title' => _x('My Subscriptions', 'Page title', 'invoicing'), |
|
| 207 | 207 | 'content' => ' |
| 208 | 208 | <!-- wp:shortcode --> |
| 209 | 209 | [wpinv_subscriptions] |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function create_pages() { |
| 225 | 225 | |
| 226 | - foreach ( self::get_pages() as $key => $page ) { |
|
| 227 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
| 226 | + foreach (self::get_pages() as $key => $page) { |
|
| 227 | + wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | global $wpdb; |
| 239 | 239 | |
| 240 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 240 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 241 | 241 | |
| 242 | 242 | // Create tables. |
| 243 | 243 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | KEY customer_and_status (customer_id, status) |
| 265 | 265 | ) $charset_collate;"; |
| 266 | 266 | |
| 267 | - dbDelta( $sql ); |
|
| 267 | + dbDelta($sql); |
|
| 268 | 268 | |
| 269 | 269 | } |
| 270 | 270 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | public function create_invoices_table() { |
| 276 | 276 | global $wpdb; |
| 277 | 277 | |
| 278 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 278 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 279 | 279 | |
| 280 | 280 | // Create tables. |
| 281 | 281 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | KEY `key` (`key`) |
| 316 | 316 | ) $charset_collate;"; |
| 317 | 317 | |
| 318 | - dbDelta( $sql ); |
|
| 318 | + dbDelta($sql); |
|
| 319 | 319 | |
| 320 | 320 | } |
| 321 | 321 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | public function create_invoice_items_table() { |
| 327 | 327 | global $wpdb; |
| 328 | 328 | |
| 329 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 329 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 330 | 330 | |
| 331 | 331 | // Create tables. |
| 332 | 332 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | KEY post_id (post_id) |
| 353 | 353 | ) $charset_collate;"; |
| 354 | 354 | |
| 355 | - dbDelta( $sql ); |
|
| 355 | + dbDelta($sql); |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
@@ -365,40 +365,40 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
| 367 | 367 | $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
| 368 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
| 368 | + $migrated = $wpdb->get_col("SELECT post_id FROM $invoices_table"); |
|
| 369 | 369 | $invoices = array_unique( |
| 370 | 370 | get_posts( |
| 371 | 371 | array( |
| 372 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
| 372 | + 'post_type' => array('wpi_invoice', 'wpi_quote'), |
|
| 373 | 373 | 'posts_per_page' => -1, |
| 374 | 374 | 'fields' => 'ids', |
| 375 | - 'post_status' => array_keys( get_post_stati() ), |
|
| 375 | + 'post_status' => array_keys(get_post_stati()), |
|
| 376 | 376 | 'exclude' => (array) $migrated, |
| 377 | 377 | ) |
| 378 | 378 | ) |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | 381 | // Abort if we do not have any invoices. |
| 382 | - if ( empty( $invoices ) ) { |
|
| 382 | + if (empty($invoices)) { |
|
| 383 | 383 | return; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
| 386 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php'); |
|
| 387 | 387 | |
| 388 | 388 | $invoice_rows = array(); |
| 389 | - foreach ( $invoices as $invoice ) { |
|
| 389 | + foreach ($invoices as $invoice) { |
|
| 390 | 390 | |
| 391 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
| 391 | + $invoice = new WPInv_Legacy_Invoice($invoice); |
|
| 392 | 392 | |
| 393 | - if ( empty( $invoice->ID ) ) { |
|
| 393 | + if (empty($invoice->ID)) { |
|
| 394 | 394 | return; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - $fields = array ( |
|
| 397 | + $fields = array( |
|
| 398 | 398 | 'post_id' => $invoice->ID, |
| 399 | 399 | 'number' => $invoice->get_number(), |
| 400 | 400 | 'key' => $invoice->get_key(), |
| 401 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
| 401 | + 'type' => str_replace('wpi_', '', $invoice->post_type), |
|
| 402 | 402 | 'mode' => $invoice->mode, |
| 403 | 403 | 'user_ip' => $invoice->get_ip(), |
| 404 | 404 | 'first_name' => $invoice->get_first_name(), |
@@ -427,27 +427,27 @@ discard block |
||
| 427 | 427 | 'custom_meta' => $invoice->payment_meta |
| 428 | 428 | ); |
| 429 | 429 | |
| 430 | - foreach ( $fields as $key => $val ) { |
|
| 431 | - if ( is_null( $val ) ) { |
|
| 430 | + foreach ($fields as $key => $val) { |
|
| 431 | + if (is_null($val)) { |
|
| 432 | 432 | $val = ''; |
| 433 | 433 | } |
| 434 | - $val = maybe_serialize( $val ); |
|
| 435 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 434 | + $val = maybe_serialize($val); |
|
| 435 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - $fields = implode( ', ', $fields ); |
|
| 438 | + $fields = implode(', ', $fields); |
|
| 439 | 439 | $invoice_rows[] = "($fields)"; |
| 440 | 440 | |
| 441 | 441 | $item_rows = array(); |
| 442 | 442 | $item_columns = array(); |
| 443 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
| 443 | + foreach ($invoice->get_cart_details() as $details) { |
|
| 444 | 444 | $fields = array( |
| 445 | 445 | 'post_id' => $invoice->ID, |
| 446 | 446 | 'item_id' => $details['id'], |
| 447 | 447 | 'item_name' => $details['name'], |
| 448 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
| 448 | + 'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'], |
|
| 449 | 449 | 'vat_rate' => $details['vat_rate'], |
| 450 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
| 450 | + 'vat_class' => empty($details['vat_class']) ? '_standard' : $details['vat_class'], |
|
| 451 | 451 | 'tax' => $details['tax'], |
| 452 | 452 | 'item_price' => $details['item_price'], |
| 453 | 453 | 'custom_price' => $details['custom_price'], |
@@ -459,31 +459,31 @@ discard block |
||
| 459 | 459 | 'fees' => $details['fees'], |
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | - $item_columns = array_keys ( $fields ); |
|
| 462 | + $item_columns = array_keys($fields); |
|
| 463 | 463 | |
| 464 | - foreach ( $fields as $key => $val ) { |
|
| 465 | - if ( is_null( $val ) ) { |
|
| 464 | + foreach ($fields as $key => $val) { |
|
| 465 | + if (is_null($val)) { |
|
| 466 | 466 | $val = ''; |
| 467 | 467 | } |
| 468 | - $val = maybe_serialize( $val ); |
|
| 469 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
| 468 | + $val = maybe_serialize($val); |
|
| 469 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - $fields = implode( ', ', $fields ); |
|
| 472 | + $fields = implode(', ', $fields); |
|
| 473 | 473 | $item_rows[] = "($fields)"; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - $item_rows = implode( ', ', $item_rows ); |
|
| 477 | - $item_columns = implode( ', ', $item_columns ); |
|
| 478 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
| 476 | + $item_rows = implode(', ', $item_rows); |
|
| 477 | + $item_columns = implode(', ', $item_columns); |
|
| 478 | + $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows"); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if ( empty( $invoice_rows ) ) { |
|
| 481 | + if (empty($invoice_rows)) { |
|
| 482 | 482 | return; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
| 486 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
| 485 | + $invoice_rows = implode(', ', $invoice_rows); |
|
| 486 | + $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows"); |
|
| 487 | 487 | |
| 488 | 488 | } |
| 489 | 489 | |
@@ -494,12 +494,12 @@ discard block |
||
| 494 | 494 | public static function rename_gateways_label() { |
| 495 | 495 | global $wpdb; |
| 496 | 496 | |
| 497 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
| 497 | + foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) { |
|
| 498 | 498 | |
| 499 | 499 | $wpdb->update( |
| 500 | 500 | $wpdb->prefix . 'getpaid_invoices', |
| 501 | - array( 'gateway' => $gateway ), |
|
| 502 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
| 501 | + array('gateway' => $gateway), |
|
| 502 | + array('gateway' => wpinv_get_gateway_admin_label($gateway)), |
|
| 503 | 503 | '%s', |
| 504 | 504 | '%s' |
| 505 | 505 | ); |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 15 | +if (!empty($required)) { |
|
| 16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | echo aui()->input( |
| 20 | 20 | array( |
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 23 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | - 'required' => ! empty( $required ), |
|
| 21 | + 'name' => esc_attr($id), |
|
| 22 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 23 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 24 | + 'required' => !empty($required), |
|
| 25 | 25 | 'label' => $label, |
| 26 | 26 | 'label_type' => 'vertical', |
| 27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 27 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 28 | 28 | 'type' => 'email', |
| 29 | 29 | 'class' => $label_class, |
| 30 | 30 | ) |
@@ -7,27 +7,27 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 15 | +if (!empty($required)) { |
|
| 16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -$current_url = ! empty( $_GET['current_url'] ) ? esc_url_raw( urldecode( $_GET['current_url'] ) ) : get_permalink(); |
|
| 19 | +$current_url = !empty($_GET['current_url']) ? esc_url_raw(urldecode($_GET['current_url'])) : get_permalink(); |
|
| 20 | 20 | echo aui()->input( |
| 21 | 21 | array( |
| 22 | - 'name' => esc_attr( $id ), |
|
| 23 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 24 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 25 | - 'required' => ! empty( $required ), |
|
| 22 | + 'name' => esc_attr($id), |
|
| 23 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 24 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 25 | + 'required' => !empty($required), |
|
| 26 | 26 | 'label' => $label, |
| 27 | 27 | 'label_type' => 'vertical', |
| 28 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 28 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 29 | 29 | 'type' => 'url', |
| 30 | - 'value' => ! empty( $default_current_post ) ? $current_url : '', |
|
| 30 | + 'value' => !empty($default_current_post) ? $current_url : '', |
|
| 31 | 31 | 'class' => $label_class, |
| 32 | 32 | ) |
| 33 | 33 | ); |
@@ -7,26 +7,26 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 15 | +if (!empty($required)) { |
|
| 16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | echo aui()->radio( |
| 20 | 20 | array( |
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 23 | - 'required' => ! empty( $required ), |
|
| 21 | + 'name' => esc_attr($id), |
|
| 22 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 23 | + 'required' => !empty($required), |
|
| 24 | 24 | 'label' => $label, |
| 25 | 25 | 'label_type' => 'vertical', |
| 26 | 26 | 'class' => 'w-auto', |
| 27 | 27 | 'inline' => false, |
| 28 | - 'options' => empty( $options ) ? array() : array_combine( $options, $options ), |
|
| 29 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 28 | + 'options' => empty($options) ? array() : array_combine($options, $options), |
|
| 29 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 30 | 30 | 'class' => $label_class, |
| 31 | 31 | ) |
| 32 | 32 | ); |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 15 | +if (!empty($required)) { |
|
| 16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | echo aui()->input( |
| 20 | 20 | array( |
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 23 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | - 'required' => ! empty( $required ), |
|
| 21 | + 'name' => esc_attr($id), |
|
| 22 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 23 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 24 | + 'required' => !empty($required), |
|
| 25 | 25 | 'label' => $label, |
| 26 | 26 | 'label_type' => 'vertical', |
| 27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 27 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 28 | 28 | 'type' => 'time', |
| 29 | 29 | 'class' => $label_class, |
| 30 | 30 | ) |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 15 | +if (!empty($required)) { |
|
| 16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | echo aui()->input( |
| 20 | 20 | array( |
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 23 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | - 'required' => ! empty( $required ), |
|
| 21 | + 'name' => esc_attr($id), |
|
| 22 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 23 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 24 | + 'required' => !empty($required), |
|
| 25 | 25 | 'label' => $label, |
| 26 | 26 | 'label_type' => 'vertical', |
| 27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 27 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 28 | 28 | 'type' => 'number', |
| 29 | 29 | 'class' => $label_class, |
| 30 | 30 | ) |
@@ -7,25 +7,25 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 15 | +if (!empty($required)) { |
|
| 16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | echo aui()->select( |
| 20 | 20 | array( |
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 23 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | - 'required' => ! empty( $required ), |
|
| 21 | + 'name' => esc_attr($id), |
|
| 22 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 23 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 24 | + 'required' => !empty($required), |
|
| 25 | 25 | 'label' => $label, |
| 26 | 26 | 'label_type' => 'vertical', |
| 27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 28 | - 'options' => empty( $options ) ? array() : array_combine( $options, $options ), |
|
| 27 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 28 | + 'options' => empty($options) ? array() : array_combine($options, $options), |
|
| 29 | 29 | 'class' => $label_class, |
| 30 | 30 | ) |
| 31 | 31 | ); |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 15 | +if (!empty($required)) { |
|
| 16 | 16 | $label .= "<span class='text-danger'> *</span>"; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | echo aui()->input( |
| 20 | 20 | array( |
| 21 | 21 | 'type' => 'checkbox', |
| 22 | - 'name' => esc_attr( $id ), |
|
| 23 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 24 | - 'required' => ! empty( $required ), |
|
| 22 | + 'name' => esc_attr($id), |
|
| 23 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 24 | + 'required' => !empty($required), |
|
| 25 | 25 | 'label' => $label, |
| 26 | - 'value' => esc_attr__( 'Yes', 'invoicing' ), |
|
| 27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 26 | + 'value' => esc_attr__('Yes', 'invoicing'), |
|
| 27 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 28 | 28 | 'class' => 'w-auto ' . $label_class, |
| 29 | 29 | ) |
| 30 | 30 | ); |