PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / trunk
Forumax – AI Powered Advanced Community Forum Plugin vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / lib / csf / fields / switcher / switcher.php

switcher.php in Forumax – AI Powered Advanced Community Forum Plugin trunk, at lib/csf/fields/switcher/switcher.php

41 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: switcher
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'CSF_Field_switcher' ) ) {
11 class CSF_Field_switcher extends CSF_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $active = ( ! empty( $this->value ) ) ? ' csf--active' : '';
20 $text_on = ( ! empty( $this->field['text_on'] ) ) ? $this->field['text_on'] : esc_html__( 'On', 'forumax' );
21 $text_off = ( ! empty( $this->field['text_off'] ) ) ? $this->field['text_off'] : esc_html__( 'Off', 'forumax' );
22 $text_width = ( ! empty( $this->field['text_width'] ) ) ? ' style="width: '. esc_attr( $this->field['text_width'] ) .'px;"': '';
23
24 echo $this->field_before();
25
26 echo '<div class="csf--switcher'. esc_attr( $active ) .'"'. $text_width .'>';
27 echo '<span class="csf--on">'. esc_attr( $text_on ) .'</span>';
28 echo '<span class="csf--off">'. esc_attr( $text_off ) .'</span>';
29 echo '<span class="csf--ball"></span>';
30 echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .' />';
31 echo '</div>';
32
33 echo ( ! empty( $this->field['label'] ) ) ? '<span class="csf--label">'. esc_attr( $this->field['label'] ) . '</span>' : '';
34
35 echo $this->field_after();
36
37 }
38
39 }
40 }
41