Plugin Directory

Changeset 3215313


Ignore:
Timestamp:
12/31/2024 11:52:39 AM (15 months ago)
Author:
infowp360
Message:

View invoice endpoint update
Invoice address fix

Location:
wp360-invoice
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp360-invoice/tags/1.0.1/front/view_invoice.php

    r3214839 r3215313  
    9494        $addressParts = [];
    9595        if (!empty($custLine1)) {
    96             $addressParts[] = $custLine1;
     96            $addressParts[] = $custLine1 . ',';
    9797        }
    9898        if (!empty($custLine2)) {
    99             $addressParts[] = (!empty($custLine1) ? "<br>" : "") . $custLine2;
    100         }
     99            $addressParts[] = $custLine2 . ',';
     100        }
     101
     102        // Combine city, postcode, state, and country into a single line.
     103        $locationParts = [];
    101104        if (!empty($custCity)) {
    102             $addressParts[] = $custCity;
     105            $locationParts[] = $custCity;
    103106        }
    104107        if (!empty($custPostCode)) {
    105             $addressParts[] = $custPostCode;
     108            $locationParts[] = $custPostCode;
    106109        }
    107110        if (!empty($custState)) {
    108             $addressParts[] = $custState;
     111            $locationParts[] = $custState;
    109112        }
    110113        if (!empty($custCountry)) {
    111             $addressParts[] = $custCountry;
    112         }
    113         $custAddress    = esc_html(implode(', ', $addressParts));
    114         $custAddress = $custLine1.' <br> '.$custCity.', '.$custPostCode.', '.$custState.', '.$custCountry;
     114            $locationParts[] = $custCountry;
     115        }
     116
     117        // Add location line to address parts, if present.
     118        if (!empty($locationParts)) {
     119            $addressParts[] = implode(', ', $locationParts);
     120        }
     121
     122        // Format the final address with line breaks.
     123        $custAddress = wp_kses_post(implode('<br>', $addressParts));
     124
    115125        $invoiceItems   = get_post_meta($invoiceID, 'invoice_items', true);
    116126        $invoicetype    = esc_html(get_post_meta($invoiceID, 'invoice_type', true));
  • wp360-invoice/tags/1.0.1/suite/index.php

    r3214839 r3215313  
    1212            add_action('wp_ajax_generate_invoice_pdf', array($this, 'wp360_invoice_generate_pdf'));
    1313            add_action('wp_ajax_nopriv_generate_invoice_pdf', array($this, 'wp360_invoice_generate_pdf'));
     14            register_activation_hook(__FILE__, array($this, 'wp360invoice_refresh_permalinks'));
     15            add_action('upgrader_process_complete', array($this, 'wp360invoice_handle_plugin_update'), 10, 2);
    1416        }
    1517        public function wp360_invoice_generate_pdf() {
     
    160162            }           
    161163        }
     164        public function wp360invoice_refresh_permalinks() {
     165            flush_rewrite_rules();
     166        }
     167        public function wp360invoice_handle_plugin_update($upgrader_object, $options) {
     168            // Ensure this is for a plugin update
     169            if ($options['action'] === 'update' && $options['type'] === 'plugin') {
     170                $current_plugin_path = plugin_basename(__FILE__);
     171                if (in_array($current_plugin_path, $options['plugins'])) {
     172                    $this->wp360invoice_refresh_permalinks();
     173                }
     174            }
     175        }
    162176    }
    163177    // Instantiate the class
  • wp360-invoice/trunk/front/view_invoice.php

    r3214855 r3215313  
    9494        $addressParts = [];
    9595        if (!empty($custLine1)) {
    96             $addressParts[] = $custLine1;
     96            $addressParts[] = $custLine1 . ',';
    9797        }
    9898        if (!empty($custLine2)) {
    99             $addressParts[] = (!empty($custLine1) ? "<br>" : "") . $custLine2;
    100         }
     99            $addressParts[] = $custLine2 . ',';
     100        }
     101
     102        // Combine city, postcode, state, and country into a single line.
     103        $locationParts = [];
    101104        if (!empty($custCity)) {
    102             $addressParts[] = $custCity;
     105            $locationParts[] = $custCity;
    103106        }
    104107        if (!empty($custPostCode)) {
    105             $addressParts[] = $custPostCode;
     108            $locationParts[] = $custPostCode;
    106109        }
    107110        if (!empty($custState)) {
    108             $addressParts[] = $custState;
     111            $locationParts[] = $custState;
    109112        }
    110113        if (!empty($custCountry)) {
    111             $addressParts[] = $custCountry;
    112         }
    113         $custAddress    = esc_html(implode(', ', $addressParts));
    114         $custAddress = $custLine1.' <br> '.$custCity.', '.$custPostCode.', '.$custState.', '.$custCountry;
     114            $locationParts[] = $custCountry;
     115        }
     116
     117        // Add location line to address parts, if present.
     118        if (!empty($locationParts)) {
     119            $addressParts[] = implode(', ', $locationParts);
     120        }
     121
     122        // Format the final address with line breaks.
     123        $custAddress = wp_kses_post(implode('<br>', $addressParts));
     124
    115125        $invoiceItems   = get_post_meta($invoiceID, 'invoice_items', true);
    116126        $invoicetype    = esc_html(get_post_meta($invoiceID, 'invoice_type', true));
  • wp360-invoice/trunk/suite/index.php

    r3214855 r3215313  
    1212            add_action('wp_ajax_generate_invoice_pdf', array($this, 'wp360_invoice_generate_pdf'));
    1313            add_action('wp_ajax_nopriv_generate_invoice_pdf', array($this, 'wp360_invoice_generate_pdf'));
     14            register_activation_hook(__FILE__, array($this, 'wp360invoice_refresh_permalinks'));
     15            add_action('upgrader_process_complete', array($this, 'wp360invoice_handle_plugin_update'), 10, 2);
    1416        }
    1517        public function wp360_invoice_generate_pdf() {
     
    160162            }           
    161163        }
     164        public function wp360invoice_refresh_permalinks() {
     165            flush_rewrite_rules();
     166        }
     167        public function wp360invoice_handle_plugin_update($upgrader_object, $options) {
     168            // Ensure this is for a plugin update
     169            if ($options['action'] === 'update' && $options['type'] === 'plugin') {
     170                $current_plugin_path = plugin_basename(__FILE__);
     171                if (in_array($current_plugin_path, $options['plugins'])) {
     172                    $this->wp360invoice_refresh_permalinks();
     173                }
     174            }
     175        }
    162176    }
    163177    // Instantiate the class
Note: See TracChangeset for help on using the changeset viewer.