Server IP : 172.67.157.199 / Your IP : 18.191.210.170 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/plugins/gravityforms/includes/settings/fields/ |
Upload File : |
<?php namespace Gravity_Forms\Gravity_Forms\Settings\Fields; use Gravity_Forms\Gravity_Forms\Settings\Fields; defined( 'ABSPATH' ) || die(); class Toggle extends Base { /** * Field type. * * @since 2.5 * * @var string */ public $type = 'toggle'; /** * Message to display for screen readers. * * @since 2.5 * * @var string */ public $toggle_label; // # RENDER METHODS ------------------------------------------------------------------------------------------------ /** * Render field. * * @since 2.5 * * @return string */ public function markup() { // Determine if toggle is selected. $enabled = $this->get_value(); // Prepare input ID. $input_id = sprintf( '%s_%s', esc_attr( $this->settings->get_input_name_prefix() ), esc_attr( $this->name ) ); // Display description. $html = $this->get_description(); $html .= '<span class="' . esc_attr( $this->get_container_classes() ) . '">'; // Insert checkbox. $html .= sprintf( '<input type="checkbox" name="%1$s" id="%1$s" value="1" %2$s %3$s %4$s />', $input_id, checked( '1', $enabled, false ), $this->get_describer() ? sprintf( 'aria-describedby="%s"', $this->get_describer() ) : '', implode( ' ', $this->get_attributes() ) ); // Insert toggle UI. $html .= sprintf( '<label class="gform-field__toggle-container" for="%s">', $input_id ); $html .= $this->toggle_label ? sprintf( '<span class="screen-reader-text">%s</span>', rgar( $this, 'label' ) ? esc_html( $this->toggle_label ) : '' ) : ''; $html .= '<span class="gform-field__toggle-switch"></span>'; $html .= '</label>'; // Insert after input markup. $html .= rgobj( $this, 'after_input' ); // If field failed validation, add error icon. $html .= $this->get_error_icon(); $html .= '</span>'; return $html; } } Fields::register( 'toggle', '\Gravity_Forms\Gravity_Forms\Settings\Fields\Toggle' );