Ecommerce Shopify WordPress Discussion

Overwrite WordPress plugin function for translation

My WP theme comes with a function that shows working hours, the name of the days are hardcoded in the script, I'd like to translate them without editing the plugin files. PLUGIN CODE <?php if ( ! function_exists( 'montagne_core_include_working_hours_shortcodes' ) ) { /** * Function that includes shortcodes */ function montagne_core_include_working_hours_shortcodes() { foreach ( glob( MONTAGNE_CORE_INC_PATH . '/working-hours/shortcodes/*/include.php' ) as $shortcode ) { include_once $shortcode; } } add_action( 'qode_framework_action_before_shortcodes_register', 'montagne_core_include_working_hours_shortcodes' ); } if ( ! function_exists( 'montagne_core_include_working_hours_widgets' ) ) { /** * Function that includes widgets */ function montagne_core_include_working_hours_widgets() { foreach ( glob( MONTAGNE_CORE_INC_PATH . '/working-hours/shortcodes/*/widget/include.php' ) as $widget ) { include_once $widget; } } add_action( 'qode_framework_action_before_widgets_register', 'montagne_core_include_working_hours_widgets' ); } if ( ! function_exists( 'montagne_core_set_working_hours_template_params' ) ) { /** * Function that set working hours area content parameters * * @param array $params * * @return array */ function montagne_core_set_working_hours_template_params( $params ) { $days = array( 'monday' => esc_html__( 'Monday', 'montagne-core' ), 'tuesday' => esc_html__( 'Tuesday', 'montagne-core' ), 'wednesday' => esc_html__( 'Wednesday', 'montagne-core' ), 'thursday' => esc_html__( 'Thursday', 'montagne-core' ), 'friday' => esc_html__( 'Friday', 'montagne-core' ), 'saturday' => esc_html__( 'Saturday', 'montagne-core' ), 'sunday' => esc_html__( 'Sunday', 'montagne-core' ), ); foreach ( $days as $day => $label ) { $option = montagne_core_get_post_value_through_levels( 'qodef_working_hours_' . $day ); $params[ $day ] = ! empty( $option ) ? esc_attr( $option ) : ''; } return $params; } add_filter( 'montagne_core_filter_working_hours_template_params', 'montagne_core_set_working_hours_template_params' ); } if ( ! function_exists( 'montagne_core_set_working_hours_special_template_params' ) ) { /** * Function that set working hours area special content parameters * * @param array $params * * @return array */ function montagne_core_set_working_hours_special_template_params( $params ) { $special_days = montagne_core_get_post_value_through_levels( 'qodef_working_hours_special_days' ); $special_text = montagne_core_get_post_value_through_levels( 'qodef_working_hours_special_text' ); if ( ! empty( $special_days ) ) { $special_days = array_filter( (array) $special_days, 'strlen' ); } $params['special_days'] = $special_days; $params['special_text'] = esc_attr( $special_text ); return $params; } add_filter( 'montagne_core_filter_working_hours_special_template_params', 'montagne_core_set_working_hours_special_template_params' ); } if ( ! function_exists( 'montagne_core_working_hours_set_admin_options_map_position' ) ) { /** * Function that set dashboard admin options map position for this module * * @param int $position * @param string $map * * @return int */ function montagne_core_working_hours_set_admin_options_map_position( $position, $map ) { if ( 'working-hours' === $map ) { $position = 90; } return $position; } add_filter( 'montagne_core_filter_admin_options_map_position', 'montagne_core_working_hours_set_admin_options_map_position', 10, 2 ); } This is how they are displayed in the HTML, using <?php echo esc_html( $day ); ?>: <div <?php qode_framework_class_attribute( $holder_classes ); ?>> <?php foreach ( $params['working_hours_params'] as $day => $time ) : ?> <div class="qodef-working-hours-item qodef-e"> <?php if ( ! empty( $day ) ) : ?> <h6 class="qodef-e-day"><?php echo esc_html( $day ); ?> <?php foreach ( $params['working_hours_special_params']['special_days'] as $special ) : if ( $day === $special ) : echo qode_framework_icons()->render_icon( 'icon_star', 'elegant-icons', array( 'icon_attributes' => array( 'class' => 'qodef-e-day-icon' ) ) ); endif; endforeach; ?> </h6> <?php endif; ?> <div class="qodef-e-line"></div> <?php if ( ! empty( $time ) ) { ?> <h6 class="qodef-e-time"><?php echo esc_html( $time ); ?></h6> <?php } else { ?> <h6 class="qodef-e-time qodef--closed"><?php esc_html_e( 'Closed', 'montagne-core' ); ?></h6> <?php } ?> </div> <?php endforeach; ?> <div class="qodef-m-footer"> <?php if ( isset( $params['working_hours_special_params']['special_text'] ) && ! empty( $params['working_hours_special_params']['special_text'] ) ) : ?> <span class="qodef-m-footer-label"><?php echo esc_html( $params['working_hours_special_params']['special_text'] ); ?></span> <?php endif; ?> <?php echo qode_framework_icons()->render_icon( 'icon_star', 'elegant-icons', array( 'icon_attributes' => array( 'class' => 'qodef-m-footer-icon' ) ) ); ?> </div> </div> I tried replacing the function in my functions.php but I still see the english ones: if ( ! function_exists( 'montagne_core_set_working_hours_template_params' ) ) { /** * Function that set working hours area content parameters * * @param array $params * * @return array */ function montagne_core_set_working_hours_template_params( $params ) { $days = array( 'lunedì' => custom_translate( 'Lunedì' ), 'martedì' => custom_translate( 'Martedì' ), 'mercoledì' => custom_translate( 'Mercoledì' ), 'giovedì' => custom_translate( 'Giovedì' ), 'venerdì' => custom_translate( 'Venerdì' ), 'sabato' => custom_translate( 'Sabato' ), 'domenica' => custom_translate( 'Domenica' ), ); foreach ( $days as $day => $label ) { $option = montagne_core_get_post_value_through_levels( 'qodef_working_hours_' . $day ); $params[ $day ] = ! empty( $option ) ? esc_attr( $option ) : ''; } return $params; } add_filter( 'montagne_core_filter_working_hours_template_params', 'montagne_core_set_working_hours_template_params' ); /** * Custom translation function * * @param string $text * * @return string */ function custom_translate( $text ) { return esc_html__( $text, 'montagne-core' ); } }
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.