# easy-hotel/2.0.2/admin/includes/framework/fields/switcher/switcher.php

Easy Hotel – Powerful Hotel Booking, version 2.0.2. 41 lines.

- Page: https://pluginprobe.com/plugins/easy-hotel/2.0.2/code/admin/includes/framework/fields/switcher/switcher.php
- Raw: https://pluginprobe.com/plugins/easy-hotel/2.0.2/raw/admin/includes/framework/fields/switcher/switcher.php
- Modified: 2026-06-15T17:21:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-hotel/2.0.2/code/admin/includes/framework/fields/switcher/switcher.php#L10-L20`.

```php
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
/**
 *
 * Field: switcher
 *
 * @since 1.0.0
 * @version 1.0.0
 *
 */
if ( ! class_exists( 'ESHB_Field_switcher' ) ) {
  class ESHB_Field_switcher extends ESHB_Fields {

    public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
      parent::__construct( $field, $value, $unique, $where, $parent );
    }

    public function render() {

      $active     = ( ! empty( $this->value ) ) ? ' csf--active' : '';
      $text_on    = ( ! empty( $this->field['text_on'] ) ) ? $this->field['text_on'] : esc_html__( 'On', 'easy-hotel' );
      $text_off   = ( ! empty( $this->field['text_off'] ) ) ? $this->field['text_off'] : esc_html__( 'Off', 'easy-hotel' );
      $text_width = ( ! empty( $this->field['text_width'] ) ) ? ' style="width: '. esc_attr( $this->field['text_width'] ) .'px;"': '';

      echo wp_kses_post($this->field_before());

      echo '<div class="csf--switcher'. esc_attr( $active ) .'"'. esc_attr($text_width) .'>';
      echo '<span class="csf--on">'. esc_attr( $text_on ) .'</span>';
      echo '<span class="csf--off">'. esc_attr( $text_off ) .'</span>';
      echo '<span class="csf--ball"></span>';
      echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. esc_attr($this->field_attributes()) .' />';
      echo '</div>';

      echo ( ! empty( $this->field['label'] ) ) ? '<span class="csf--label">'. esc_attr( $this->field['label'] ) . '</span>' : '';

      echo wp_kses_post($this->field_after());

    }

  }
}

```
