Skip to content

Commit

Permalink
Skip label reference default options on install.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Jul 4, 2024
1 parent edc4250 commit 571c668
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Admin/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ public function column_title( $shipment ) {
</article>
<footer>
<div class="inner">
<a id="btn-ok" class="button button-primary button-large" href="<?php echo esc_url( $shipment->get_edit_shipment_url() ); ?>"><?php echo esc_html_x( 'Edit', 'shipments', 'woocommerce-germanized-shipments' ); ?></a>
<a class="button button-primary button-large" href="<?php echo esc_url( $shipment->get_edit_shipment_url() ); ?>"><?php echo esc_html_x( 'Edit', 'shipments', 'woocommerce-germanized-shipments' ); ?></a>
</div>
</footer>
</section>
Expand Down
17 changes: 9 additions & 8 deletions src/ShippingProvider/Auto.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,15 @@ protected function get_label_settings_by_shipment_type( $shipment_type = 'simple
$shipment_label_title = wc_gzd_get_shipment_label_title( $shipment_type );

$reference_settings[] = array(
'title' => $reference_type_data['label'],
'desc' => '<div class="wc-gzd-additional-desc">' . sprintf( _x( 'Adjust %1$s printed on the %2$s label. Use the following placeholders to format the reference: %3$s', 'shipments', 'woocommerce-germanized-shipments' ), $reference_type_data['label'], $shipment_label_title, $formatted_placeholders ) . ( -1 !== $reference_type_data['max_length'] ? sprintf( _x( 'Please keep in mind that the formatted reference cannot exceed %1$s characters.', 'shipments', 'woocommerce-germanized-shipments' ), $reference_type_data['max_length'] ) : '' ) . '</div>',
'id' => "shipping_provider_label_reference_{$shipment_type}_{$reference_type}",
'placeholder' => $reference_type_data['default'],
'value' => $this->get_label_reference( $shipment_type, $reference_type, 'edit' ),
'default' => $reference_type_data['default'],
'type' => 'textarea',
'css' => 'width: 100%; min-height: 60px; margin-top: 1em;',
'title' => $reference_type_data['label'],
'desc' => '<div class="wc-gzd-additional-desc">' . sprintf( _x( 'Adjust %1$s printed on the %2$s label. Use the following placeholders to format the reference: %3$s', 'shipments', 'woocommerce-germanized-shipments' ), $reference_type_data['label'], $shipment_label_title, $formatted_placeholders ) . ( -1 !== $reference_type_data['max_length'] ? sprintf( _x( 'Please keep in mind that the formatted reference cannot exceed %1$s characters.', 'shipments', 'woocommerce-germanized-shipments' ), $reference_type_data['max_length'] ) : '' ) . '</div>',
'id' => "shipping_provider_label_reference_{$shipment_type}_{$reference_type}",
'placeholder' => $reference_type_data['default'],
'value' => $this->get_label_reference( $shipment_type, $reference_type, 'edit' ),
'default' => $reference_type_data['default'],
'skip_install' => true,
'type' => 'textarea',
'css' => 'width: 100%; min-height: 60px; margin-top: 1em;',
);
}

Expand Down
11 changes: 9 additions & 2 deletions src/ShippingProvider/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,16 @@ public function set_supports_guest_returns( $supports ) {
}

protected function setting_supports_default_update( $setting ) {
$type = isset( $setting['type'] ) ? $setting['type'] : 'title';
$setting = wp_parse_args(
$setting,
array(
'type' => 'title',
'id' => '',
'skip_install' => false,
)
);

if ( in_array( $type, array( 'title', 'sectionend', 'html' ), true ) || ! isset( $setting['id'] ) || empty( $setting['id'] ) ) {
if ( in_array( $setting['type'], array( 'title', 'sectionend', 'html' ), true ) || empty( $setting['id'] ) || $setting['skip_install'] ) {
return false;
}

Expand Down

0 comments on commit 571c668

Please sign in to comment.