array( array( domain, original ) ) ). */ function dayslot_customer_texts() { $d = 'dayslot'; return apply_filters( 'dayslot_customer_texts', array( __( 'Picker', 'dayslot' ) => array( array( $d, '— choose time —' ), array( $d, 'Choose time' ), array( $d, 'Choose a date first' ), array( $d, 'Loading…' ), array( $d, 'No free times on this day. Please choose another date.' ), array( $d, 'full' ), array( $d, 'left: %d' ), array( $d, 'Higher price on this day' ), array( $d, 'not available' ), array( $d, 'selected' ), array( $d, 'Previous month' ), array( $d, 'Next month' ), array( $d, 'Please enable JavaScript to choose the delivery date.' ), ), __( 'Prices and day types', 'dayslot' ) => array( array( $d, 'Mon–Sat' ), array( $d, 'Sunday' ), array( $d, 'Holiday' ), array( $d, 'Delivery price' ), array( $d, 'Price' ), array( $d, '%s (price after choosing the date and time)' ), array( $d, '%s (night)' ), ), __( 'Messages', 'dayslot' ) => array( array( $d, 'Please choose how you want to receive the order.' ), array( $d, 'The delivery price has been updated for your choice. Please check the total and place the order again.' ), ), __( 'Emails', 'dayslot' ) => array( array( $d, 'Your delivery date has changed' ), array( $d, '[%1$s] New delivery date for order #%2$s' ), array( $d, 'Hi %s,' ), array( $d, 'The delivery date for your order #%s has been changed:' ), array( $d, 'If this doesn\'t suit you, just reply to this email.' ), ), ) ); } function dayslot_text_key( $domain, $text ) { return md5( $domain . '|' . $text ); } /** * Apply the shop's own texts. */ function dayslot_text_override( $translation, $text, $domain ) { static $texts = null; if ( null === $texts ) { $texts = get_option( 'dayslot_texts', array() ); $texts = is_array( $texts ) ? $texts : array(); } if ( ! $texts ) { return $translation; } $key = dayslot_text_key( $domain, $text ); if ( ! isset( $texts[ $key ] ) || '' === $texts[ $key ] ) { return $translation; } // Multilingual shops: the own text can follow the page language (includes/multilingual.php). return (string) apply_filters( 'dayslot_text_override', $texts[ $key ], $text, $translation ); } if ( get_option( 'dayslot_texts' ) ) { foreach ( array( 'dayslot', 'dayslot' ) as $dayslot_domain ) { add_filter( 'gettext_' . $dayslot_domain, 'dayslot_text_override', 10, 3 ); } unset( $dayslot_domain ); } add_filter( 'dayslot_settings_tabs', function ( $tabs ) { $tabs['texts'] = array( 'title' => __( 'Texts', 'dayslot' ), 'render' => 'dayslot_render_texts_tab', 'sanitize' => function ( $input, $out ) { $clean = array(); $valid = array(); foreach ( dayslot_customer_texts() as $list ) { foreach ( $list as $item ) { $valid[ dayslot_text_key( $item[0], $item[1] ) ] = true; } } foreach ( isset( $input['texts'] ) ? (array) $input['texts'] : array() as $key => $value ) { $value = sanitize_text_field( $value ); if ( isset( $valid[ $key ] ) && '' !== $value ) { $clean[ $key ] = $value; } } update_option( 'dayslot_texts', $clean, true ); $language = isset( $input['language'] ) ? sanitize_text_field( $input['language'] ) : ''; if ( isset( dayslot_languages()[ $language ] ) ) { $out['language'] = $language; } else { unset( $out['language'] ); } return $out; }, ); return $tabs; }, 50 ); function dayslot_render_texts_tab( $s ) { $saved = get_option( 'dayslot_texts', array() ); $saved = is_array( $saved ) ? $saved : array(); // Show the originals, not our overrides. remove_filter( 'gettext_dayslot', 'dayslot_text_override', 10 ); remove_filter( 'gettext_dayslot', 'dayslot_text_override', 10 ); $language = isset( $s['language'] ) ? $s['language'] : ''; $wp_locale = dayslot_closest_locale( determine_locale() ); $wp_name = isset( dayslot_languages()[ $wp_locale ] ) ? dayslot_languages()[ $wp_locale ] : 'English'; ?>


$list ) : ?>

translate( $item[1] ); ?>