Skip to content

Commit

Permalink
Merge branch 'main' into 857-setup-wizard-update
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmigf committed Jan 20, 2025
2 parents 387f14c + 3b82aef commit 29813d2
Show file tree
Hide file tree
Showing 15 changed files with 834 additions and 365 deletions.
1 change: 1 addition & 0 deletions assets/css/settings-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ body.woocommerce_page_wpo_wcpdf_options_page {

#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > input[type="text"],
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > input[type="url"],
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > input[type="email"],
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > select,
#wpo-wcpdf-preview-wrapper .sidebar .form-table > tbody > tr > td > textarea {
max-width: none;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/settings-styles.min.css

Large diffs are not rendered by default.

47 changes: 6 additions & 41 deletions includes/Documents/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,12 @@ public function get_ubl_settings_fields( $option_name ) {
'options' => apply_filters( 'wpo_wcpdf_document_ubl_settings_formats', array(
'ubl_2_1' => __( 'UBL 2.1' , 'woocommerce-pdf-invoices-packing-slips' ),
), $this ),
'description' => $this->get_ubl_format_description(),
'description' => ! wpo_ips_ubl_is_country_format_extension_active() ? sprintf(
/* translators: %1$s: opening link tag, %2$s: closing link tag */
__( 'Install extensions to support country-specific e-invoicing formats. See the latest %1$ssupported formats%2$s.', 'woocommerce-pdf-invoices-packing-slips' ),
'<a href="https://github.com/wpovernight/wpo-ips-einvoicing" target="_blank">',
'</a>'
) : '',
)
),
array(
Expand Down Expand Up @@ -713,46 +718,6 @@ public function get_settings_categories( string $output_format ): array {
return apply_filters( 'wpo_wcpdf_document_settings_categories', $settings_categories[ $output_format ] ?? array(), $output_format, $this );
}

/**
* Get UBL Format setting description
*
* @return string
*/
private function get_ubl_format_description(): string {
$extensions_available = array();
$ubl_format_description = '';

if ( ! class_exists( 'WPO_IPS_XRechnung' ) ) {
$extensions_available['xrechnung'] = array(
'title' => __( 'EN16931 XRechnung', 'woocommerce-pdf-invoices-packing-slips' ),
'url' => 'https://github.com/wpovernight/wpo-ips-xrechnung/releases/latest/',
);
}

if ( ! empty( $extensions_available ) ) {
$ubl_format_description = __( 'Formats available through extensions', 'woocommerce-pdf-invoices-packing-slips' ) . ':';

foreach ( $extensions_available as $extension ) {
$ubl_format_description .= ' <a href="' . esc_url( $extension['url'] ) . '" target="_blank">' . esc_html( $extension['title'] ) . '</a>';

if ( next( $extensions_available ) ) {
$ubl_format_description .= ',';
} else {
$ubl_format_description .= '<br>';
}
}
}

$ubl_format_description .= sprintf(
/* translators: %1$s: opening link tag, %2$s: closing link tag */
__( 'If the format you need isn\'t listed, please don\'t hesitate to %1$scontact us%2$s!', 'woocommerce-pdf-invoices-packing-slips' ),
'<a href="https://wpovernight.com/contact/" target="_blank">',
'</a>'
);

return $ubl_format_description;
}

}

endif; // class_exists
2 changes: 1 addition & 1 deletion includes/Documents/OrderDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public function regenerate( $order = null, $data = null ) {
}

// ubl
if ( $document->is_enabled( 'ubl' ) && wcpdf_is_ubl_available() ) {
if ( $this->is_enabled( 'ubl' ) && wcpdf_is_ubl_available() ) {
wpo_ips_ubl_save_order_taxes( $order );
}

Expand Down
29 changes: 29 additions & 0 deletions includes/Settings/SettingsCallbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,35 @@ public function url_input( $args ) {
}
}

/**
* Email input callback.
*
* args:
* option_name - name of the main option
* id - key of the setting
* size - size of the text input (em)
* default - default setting (optional)
* description - description (optional)
* type - type (optional)
*
* @return void.
*/
public function email_input( $args ) {
extract( $this->normalize_settings_args( $args ) );

if ( empty( $type ) ) {
$type = 'email';
}

$size = ! empty( $size ) ? sprintf( 'size="%s"', esc_attr( $size ) ) : '';
printf( '<input type="%1$s" id="%2$s" name="%3$s" value="%4$s" %5$s placeholder="%6$s" %7$s/>', esc_attr( $type ), esc_attr( $id ), esc_attr( $setting_name ), sanitize_email( $current ), $size, esc_attr( $placeholder ), ! empty( $disabled ) ? 'disabled="disabled"' : '' );

// output description.
if ( ! empty( $description ) ) {
printf( '<p class="description">%s</p>', wp_kses_post( $description ) );
}
}

/**
* Combined checkbox & text input callback.
*
Expand Down
Loading

0 comments on commit 29813d2

Please sign in to comment.