@@ -9,58 +9,58 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // If uninstall not called from WordPress, then exit. |
| 12 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 12 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | global $wpdb, $wp_version; |
| 17 | 17 | |
| 18 | -$remove_data = get_option( 'wpinv_remove_data_on_invoice_unistall' ); |
|
| 18 | +$remove_data = get_option('wpinv_remove_data_on_invoice_unistall'); |
|
| 19 | 19 | |
| 20 | 20 | /* |
| 21 | 21 | * Only remove ALL product and page data if WPINV_REMOVE_ALL_DATA constant is set to true in user's |
| 22 | 22 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
| 23 | 23 | * and to ensure only the site owner can perform this action. |
| 24 | 24 | */ |
| 25 | -if ( defined( 'WPINV_REMOVE_ALL_DATA' ) ) { |
|
| 25 | +if (defined('WPINV_REMOVE_ALL_DATA')) { |
|
| 26 | 26 | $remove_data = true === WPINV_REMOVE_ALL_DATA ? true : false; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if ( $remove_data ) { |
|
| 29 | +if ($remove_data) { |
|
| 30 | 30 | // Load Invoicing file. |
| 31 | - include_once( 'invoicing.php' ); |
|
| 31 | + include_once('invoicing.php'); |
|
| 32 | 32 | |
| 33 | 33 | // Roles + caps. |
| 34 | - include_once( dirname( __FILE__ ) . '/includes/admin/install.php' ); |
|
| 34 | + include_once(dirname(__FILE__) . '/includes/admin/install.php'); |
|
| 35 | 35 | wpinv_remove_admin_caps(); |
| 36 | 36 | |
| 37 | - $settings = get_option( 'wpinv_settings' ); |
|
| 37 | + $settings = get_option('wpinv_settings'); |
|
| 38 | 38 | |
| 39 | 39 | // Delete pages. |
| 40 | - $wpi_pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page' ); |
|
| 41 | - foreach ( $wpi_pages as $page ) { |
|
| 42 | - if ( !empty( $page ) && !empty( $settings[ $page ] ) ) { |
|
| 43 | - wp_delete_post( $settings[ $page ], true ); |
|
| 40 | + $wpi_pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page'); |
|
| 41 | + foreach ($wpi_pages as $page) { |
|
| 42 | + if (!empty($page) && !empty($settings[$page])) { |
|
| 43 | + wp_delete_post($settings[$page], true); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Delete posts + data. |
| 48 | - $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );" ); |
|
| 49 | - $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); |
|
| 48 | + $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );"); |
|
| 49 | + $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;"); |
|
| 50 | 50 | |
| 51 | 51 | // Delete comments. |
| 52 | - $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';" ); |
|
| 53 | - $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" ); |
|
| 52 | + $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';"); |
|
| 53 | + $wpdb->query("DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;"); |
|
| 54 | 54 | |
| 55 | 55 | // Delete user meta. |
| 56 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';" ); |
|
| 56 | + $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';"); |
|
| 57 | 57 | |
| 58 | 58 | // Cleanup Cron Schedule |
| 59 | - wp_clear_scheduled_hook( 'wp_session_garbage_collection' ); |
|
| 60 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 59 | + wp_clear_scheduled_hook('wp_session_garbage_collection'); |
|
| 60 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
| 61 | 61 | |
| 62 | 62 | // Delete options. |
| 63 | - $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';" ); |
|
| 63 | + $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';"); |
|
| 64 | 64 | |
| 65 | 65 | // Clear any cached data that has been removed |
| 66 | 66 | wp_cache_flush(); |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,156 +1,156 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
| 4 | - if ( empty( $invoice ) ) { |
|
| 3 | +function wpinv_is_subscription_payment($invoice = '') { |
|
| 4 | + if (empty($invoice)) { |
|
| 5 | 5 | return false; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 9 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 8 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 9 | + $invoice = wpinv_get_invoice($invoice); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - if ( empty( $invoice ) ) { |
|
| 12 | + if (empty($invoice)) { |
|
| 13 | 13 | return false; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - if ( $invoice->is_renewal() ) { |
|
| 16 | + if ($invoice->is_renewal()) { |
|
| 17 | 17 | return true; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | return false; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
| 24 | - if ( empty( $invoice ) ) { |
|
| 23 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
| 24 | + if (empty($invoice)) { |
|
| 25 | 25 | return false; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 29 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 28 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 29 | + $invoice = wpinv_get_invoice($invoice); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if ( empty( $invoice ) ) { |
|
| 32 | + if (empty($invoice)) { |
|
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
| 36 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
| 39 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
| 40 | 40 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 41 | 41 | |
| 42 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 43 | - $amount = __( 'Free', 'invoicing' ); |
|
| 42 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 43 | + $amount = __('Free', 'invoicing'); |
|
| 44 | 44 | $interval = $trial_interval; |
| 45 | 45 | $period = $trial_period; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $description = ''; |
| 49 | - switch ( $period ) { |
|
| 49 | + switch ($period) { |
|
| 50 | 50 | case 'D' : |
| 51 | 51 | case 'day' : |
| 52 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 52 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 53 | 53 | break; |
| 54 | 54 | case 'W' : |
| 55 | 55 | case 'week' : |
| 56 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 56 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 57 | 57 | break; |
| 58 | 58 | case 'M' : |
| 59 | 59 | case 'month' : |
| 60 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 60 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 61 | 61 | break; |
| 62 | 62 | case 'Y' : |
| 63 | 63 | case 'year' : |
| 64 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 64 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 65 | 65 | break; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 68 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
| 71 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
| 72 | 72 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 73 | 73 | $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
| 74 | 74 | |
| 75 | 75 | $description = ''; |
| 76 | - switch ( $period ) { |
|
| 76 | + switch ($period) { |
|
| 77 | 77 | case 'D' : |
| 78 | 78 | case 'day' : |
| 79 | - if ( (int)$bill_times > 0 ) { |
|
| 80 | - if ( $interval > 1 ) { |
|
| 81 | - if ( $bill_times > 1 ) { |
|
| 82 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 79 | + if ((int)$bill_times > 0) { |
|
| 80 | + if ($interval > 1) { |
|
| 81 | + if ($bill_times > 1) { |
|
| 82 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 83 | 83 | } else { |
| 84 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
| 84 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 87 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 88 | 88 | } |
| 89 | 89 | } else { |
| 90 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
| 90 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | 93 | case 'W' : |
| 94 | 94 | case 'week' : |
| 95 | - if ( (int)$bill_times > 0 ) { |
|
| 96 | - if ( $interval > 1 ) { |
|
| 97 | - if ( $bill_times > 1 ) { |
|
| 98 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 95 | + if ((int)$bill_times > 0) { |
|
| 96 | + if ($interval > 1) { |
|
| 97 | + if ($bill_times > 1) { |
|
| 98 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 99 | 99 | } else { |
| 100 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
| 100 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 103 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 106 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 107 | 107 | } |
| 108 | 108 | break; |
| 109 | 109 | case 'M' : |
| 110 | 110 | case 'month' : |
| 111 | - if ( (int)$bill_times > 0 ) { |
|
| 112 | - if ( $interval > 1 ) { |
|
| 113 | - if ( $bill_times > 1 ) { |
|
| 114 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 111 | + if ((int)$bill_times > 0) { |
|
| 112 | + if ($interval > 1) { |
|
| 113 | + if ($bill_times > 1) { |
|
| 114 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 115 | 115 | } else { |
| 116 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
| 116 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
| 117 | 117 | } |
| 118 | 118 | } else { |
| 119 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 119 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 120 | 120 | } |
| 121 | 121 | } else { |
| 122 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 122 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 123 | 123 | } |
| 124 | 124 | break; |
| 125 | 125 | case 'Y' : |
| 126 | 126 | case 'year' : |
| 127 | - if ( (int)$bill_times > 0 ) { |
|
| 128 | - if ( $interval > 1 ) { |
|
| 129 | - if ( $bill_times > 1 ) { |
|
| 130 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 127 | + if ((int)$bill_times > 0) { |
|
| 128 | + if ($interval > 1) { |
|
| 129 | + if ($bill_times > 1) { |
|
| 130 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 131 | 131 | } else { |
| 132 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
| 132 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
| 133 | 133 | } |
| 134 | 134 | } else { |
| 135 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 135 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 136 | 136 | } |
| 137 | 137 | } else { |
| 138 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 138 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 139 | 139 | } |
| 140 | 140 | break; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 143 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
| 147 | - if ( empty( $invoice ) ) { |
|
| 146 | +function wpinv_subscription_payment_desc($invoice) { |
|
| 147 | + if (empty($invoice)) { |
|
| 148 | 148 | return NULL; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $description = ''; |
| 152 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
| 153 | - if ( $item->has_free_trial() ) { |
|
| 152 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
| 153 | + if ($item->has_free_trial()) { |
|
| 154 | 154 | $trial_period = $item->get_trial_period(); |
| 155 | 155 | $trial_interval = $item->get_trial_interval(); |
| 156 | 156 | } else { |
@@ -158,45 +158,45 @@ discard block |
||
| 158 | 158 | $trial_interval = 0; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
| 161 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
| 164 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
| 168 | - $initial_total = wpinv_round_amount( $initial ); |
|
| 169 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
| 167 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
| 168 | + $initial_total = wpinv_round_amount($initial); |
|
| 169 | + $recurring_total = wpinv_round_amount($recurring); |
|
| 170 | 170 | |
| 171 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 171 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 172 | 172 | // Free trial |
| 173 | 173 | } else { |
| 174 | - if ( $bill_times == 1 ) { |
|
| 174 | + if ($bill_times == 1) { |
|
| 175 | 175 | $recurring_total = $initial_total; |
| 176 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
| 176 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
| 177 | 177 | $bill_times--; |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $initial_amount = wpinv_price( wpinv_format_amount( $initial_total ), $currency ); |
|
| 182 | - $recurring_amount = wpinv_price( wpinv_format_amount( $recurring_total ), $currency ); |
|
| 181 | + $initial_amount = wpinv_price(wpinv_format_amount($initial_total), $currency); |
|
| 182 | + $recurring_amount = wpinv_price(wpinv_format_amount($recurring_total), $currency); |
|
| 183 | 183 | |
| 184 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 184 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 185 | 185 | |
| 186 | - if ( $initial_total != $recurring_total ) { |
|
| 187 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 186 | + if ($initial_total != $recurring_total) { |
|
| 187 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
| 188 | 188 | |
| 189 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
| 189 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
| 190 | 190 | } else { |
| 191 | 191 | $description = $recurring; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
| 194 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -function wpinv_recurring_send_payment_failed( $invoice ) { |
|
| 198 | - if ( !empty( $invoice->ID ) ) { |
|
| 199 | - wpinv_failed_invoice_notification( $invoice->ID ); |
|
| 197 | +function wpinv_recurring_send_payment_failed($invoice) { |
|
| 198 | + if (!empty($invoice->ID)) { |
|
| 199 | + wpinv_failed_invoice_notification($invoice->ID); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | -add_action( 'wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1 ); |
|
| 203 | 202 | \ No newline at end of file |
| 203 | +add_action('wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1); |
|
| 204 | 204 | \ No newline at end of file |