*/ trait Checkbox { /** * Hide an element_key if a controlling_checkbox is checked. * * @param string $controlling_checkbox - Name of controlling_checkbox field which controls whether to hide this * element or not. * @param ?string $element_key - Match the `element_to_reveal` passed to $this->checkbox() for the * checkbox which controls this. * @param bool $reverse - hide on check instead of show on check. * * @return void */ public function hide_element( $controlling_checkbox, $element_key = null, $reverse = false ): void { $hide = false; if ( ( $reverse && $this->checked( $controlling_checkbox ) ) || ( ! $reverse && ! $this->checked( $controlling_checkbox ) ) ) { $hide = true; } if ( null !== $element_key ) { ?> data-js="get_field_id( $element_key ) ); ?>" class="advanced-sidebar-menu-" data-advanced-sidebar-menu-hide="1" with the id and name filled. * * @param string $name - Name of field. * @param ?string $element_to_reveal - Element to reveal/hide when box is checked/unchecked. * * @return void */ public function checkbox( $name, $element_to_reveal = null ): void { ?> checked( $name ) ? 'checked' : ''; ?> /> is_checked( $name, $this->widget_settings ); } }