Skip to content

Commit

Permalink
Do only add inline food css in case options enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Nov 15, 2023
1 parent 5b15879 commit 8528a32
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion includes/admin/class-wc-gzd-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ protected function check_enable_debug_mode() {
}

protected function check_disable_food_options() {
if ( 'yes' === get_option( 'woocommerce_gzd_disable_food_options' ) ) {
if ( ! WC_GZD_Food_Helper::enable_food_options() ) {
update_option( 'woocommerce_gzd_disable_food_options', 'no' );
} else {
update_option( 'woocommerce_gzd_disable_food_options', 'yes' );
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/views/html-page-status-germanized.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
<td><?php esc_html_e( 'Food Options', 'woocommerce-germanized' ); ?></td>
<td class="help"><?php echo wc_help_tip( esc_attr( __( 'Enable/disable product food options.', 'woocommerce-germanized' ) ) ); ?></td>
<td>
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'wc-gzd-check-disable_food_options' => true ) ), 'wc-gzd-check-disable_food_options' ) ); ?>" class="button button-secondary"><?php echo ( 'yes' === get_option( 'woocommerce_gzd_disable_food_options' ) ? esc_html__( 'Enable food options', 'woocommerce-germanized' ) : esc_html__( 'Disable food options', 'woocommerce-germanized' ) ); ?></a>
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'wc-gzd-check-disable_food_options' => true ) ), 'wc-gzd-check-disable_food_options' ) ); ?>" class="button button-secondary"><?php echo ( ! WC_GZD_Food_Helper::enable_food_options() ? esc_html__( 'Enable food options', 'woocommerce-germanized' ) : esc_html__( 'Disable food options', 'woocommerce-germanized' ) ); ?></a>
</td>
</tr>
<?php if ( class_exists( 'WC_GZD_Secret_Box_Helper' ) && ! WC_GZD_Secret_Box_Helper::has_valid_encryption_key() ) : ?>
Expand Down
4 changes: 4 additions & 0 deletions includes/class-wc-gzd-food-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ public static function init() {

}

public static function enable_food_options() {
return 'yes' !== get_option( 'woocommerce_gzd_disable_food_options' );
}

public static function get_nutrient_reference_values() {
return apply_filters(
'woocommerce_gzd_nutrient_reference_values',
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-gzd-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static function register_taxonomies() {
)
);

if ( apply_filters( 'woocommerce_gzd_register_food_taxonomies', ( 'yes' !== get_option( 'woocommerce_gzd_disable_food_options' ) ) ) ) {
if ( apply_filters( 'woocommerce_gzd_register_food_taxonomies', WC_GZD_Food_Helper::enable_food_options() ) ) {
// Deposit classes
register_taxonomy(
'product_deposit_type',
Expand Down
4 changes: 3 additions & 1 deletion woocommerce-germanized.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,8 @@ public function add_inline_styles() {
$custom_css .= ' p.woocommerce-shipping-destination { display: none; }';
}

$custom_css .= '
if ( WC_GZD_Food_Helper::enable_food_options() ) {
$custom_css .= '
.wc-gzd-nutri-score-value-a {
background: url(' . esc_url( $this->plugin_url() ) . '/assets/images/nutri-score-a.svg) no-repeat;
}
Expand All @@ -1135,6 +1136,7 @@ public function add_inline_styles() {
background: url(' . esc_url( $this->plugin_url() ) . '/assets/images/nutri-score-e.svg) no-repeat;
}
';
}

wp_add_inline_style( 'woocommerce-gzd-layout', $custom_css );
}
Expand Down

0 comments on commit 8528a32

Please sign in to comment.