esc_url_raw( rest_url( Rest::NS ) ), // Only logged-in users send a nonce: cached pages would otherwise carry a stale one and fail with 403. 'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : '', 'locale' => str_replace( '_', '-', get_locale() ), 'weekStart'=> (int) get_option( 'start_of_week', 1 ), 'currency' => $s['currency'], 'symbol' => $s['currency_symbol'], 'i18n' => $this->strings(), 'design' => Design::public_config(), ) ) . ';', 'before' ); $css = Design::css( $s ); wp_add_inline_style( 'bookzenix-booking', $css ); // Font picked in Settings → Design. Shipped with the plugin (SIL Open Font License) – // nothing is loaded from Google or any other outside server. $fonts = array( 'Manrope' => 'manrope', 'Inter' => 'inter', 'Poppins' => 'poppins', 'DM Sans' => 'dm-sans', 'Lato' => 'lato', 'Open Sans' => 'open-sans', 'Roboto' => 'roboto', 'Montserrat' => 'montserrat' ); $first = trim( str_replace( array( '"', "'" ), '', (string) strtok( (string) $s['font_family'], ',' ) ) ); if ( isset( $fonts[ $first ] ) && apply_filters( 'bookzenix_load_font', true, $first ) ) { wp_enqueue_style( 'bookzenix-font', BOOKZENIX_URL . 'assets/fonts/' . $fonts[ $first ] . '/' . $fonts[ $first ] . '.css', array(), BOOKZENIX_VERSION ); } } public function booking_shortcode( $atts ) { $atts = shortcode_atts( array( 'service' => '', 'category' => '', 'employee' => '', 'layout' => '', // steps | sidebar | compact 'services' => '', // list | grid 'staff' => '', // cards | list 'slots' => '', // tickets | pills | list 'dates' => '', // month | week ), $atts, 'bookzenix_booking' ); $this->enqueue(); return sprintf( '
', esc_attr( Design::classes( $atts ) ), esc_attr( absint( $atts['service'] ) ?: '' ), esc_attr( absint( $atts['category'] ) ?: '' ), esc_attr( absint( $atts['employee'] ) ?: '' ) ); } /** Server-rendered block so the editor can drop the form anywhere. */ public function register_block() { if ( ! function_exists( 'register_block_type' ) ) { return; } register_block_type( 'bookzenix/booking', array( 'api_version' => 2, 'title' => 'Bookzenix Booking Form', 'attributes' => array( 'service' => array( 'type' => 'string', 'default' => '' ), 'category' => array( 'type' => 'string', 'default' => '' ), 'employee' => array( 'type' => 'string', 'default' => '' ), 'layout' => array( 'type' => 'string', 'default' => '' ), 'services' => array( 'type' => 'string', 'default' => '' ), 'staff' => array( 'type' => 'string', 'default' => '' ), 'slots' => array( 'type' => 'string', 'default' => '' ), 'dates' => array( 'type' => 'string', 'default' => '' ), ), 'render_callback' => array( $this, 'booking_shortcode' ), ) ); } private function strings() { $s = array( 'service' => __( 'Service', 'bookzenix' ), 'employee' => __( 'Specialist', 'bookzenix' ), 'datetime' => __( 'Date & time', 'bookzenix' ), 'details' => __( 'Your details', 'bookzenix' ), 'done' => __( 'Done', 'bookzenix' ), 'anyEmployee' => __( 'Any available specialist', 'bookzenix' ), 'continue' => __( 'Continue', 'bookzenix' ), 'back' => __( 'Back', 'bookzenix' ), 'book' => __( 'Confirm booking', 'bookzenix' ), 'noSlots' => __( 'No free times on this day. Try another date.', 'bookzenix' ), 'pickDate' => __( 'Pick a date to see available times', 'bookzenix' ), 'firstName' => __( 'First name', 'bookzenix' ), 'lastName' => __( 'Last name', 'bookzenix' ), 'email' => __( 'Email', 'bookzenix' ), 'phone' => __( 'Phone', 'bookzenix' ), 'note' => __( 'Anything we should know?', 'bookzenix' ), 'total' => __( 'Total', 'bookzenix' ), 'min' => __( 'min', 'bookzenix' ), 'successTitle' => __( "You're booked!", 'bookzenix' ), 'successText' => __( 'A confirmation has been sent to your email.', 'bookzenix' ), 'pendingText' => __( "We've received your request and will confirm it shortly.", 'bookzenix' ), 'addToCalendar' => __( 'Add to Google Calendar', 'bookzenix' ), 'bookAnother' => __( 'Book another', 'bookzenix' ), 'notNeeded' => __( 'Not needed', 'bookzenix' ), 'error' => __( 'Something went wrong. Please try again.', 'bookzenix' ), 'required' => __( 'Required', 'bookzenix' ), 'search' => __( 'Search services…', 'bookzenix' ), 'all' => __( 'All', 'bookzenix' ), 'close' => __( 'Close', 'bookzenix' ), 'offers' => __( 'Offers', 'bookzenix' ), 'from' => __( 'from', 'bookzenix' ), 'bookNow' => __( 'Book now', 'bookzenix' ), 'viewDetails' => __( 'View details', 'bookzenix' ), 'bookThis' => __( 'Book this service', 'bookzenix' ), ); return $s; } }