Yoast\WP\SEO\Presenters\Admin
Light_Switch_Presenter::present
Presents the light switch toggle.
Метод класса: Light_Switch_Presenter{}
Хуков нет.
Возвращает
Строку. The light switch's HTML.
Использование
$Light_Switch_Presenter = new Light_Switch_Presenter(); $Light_Switch_Presenter->present();
Код Light_Switch_Presenter::present() Light Switch Presenter::present Yoast 27.3
public function present() {
if ( empty( $this->buttons ) ) {
$this->buttons = [ \__( 'Disabled', 'wordpress-seo' ), \__( 'Enabled', 'wordpress-seo' ) ];
}
list( $off_button, $on_button ) = $this->buttons;
$class = 'switch-light switch-candy switch-yoast-seo';
if ( $this->reverse ) {
$class .= ' switch-yoast-seo-reverse';
}
$help_class = ! empty( $this->help ) ? ' switch-container__has-help' : '';
$strong_class = ( $this->strong ) ? ' switch-light-visual-label__strong' : '';
$output = '<div class="switch-container' . $help_class . '">';
$output .= \sprintf(
'<span class="switch-light-visual-label%1$s" id="%2$s">%3$s</span>%4$s',
$strong_class, // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: $strong_class output is hardcoded.
\esc_attr( $this->var . '-label' ),
\esc_html( $this->label ),
$this->help, // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: The help contains HTML.
);
$output .= '<label class="' . $class . '"><b class="switch-yoast-seo-jaws-a11y"> </b>';
$output .= \sprintf(
'<input type="checkbox" aria-labelledby="%1$s" id="%2$s" name="%3$s" value="on"%4$s%5$s/>',
\esc_attr( $this->var . '-label' ),
\esc_attr( $this->var ),
\esc_attr( $this->name ),
\checked( $this->value, 'on', false ), // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: The output is hardcoded by WordPress.
$this->disabled_attribute, // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: $disabled_attribute output is hardcoded.
);
$output .= '<span aria-hidden="true">';
$output .= '<span>' . \esc_html( $off_button ) . '</span>';
$output .= '<span>' . \esc_html( $on_button ) . '</span>';
$output .= '<a></a>';
$output .= '</span></label><div class="clear"></div></div>';
return $output;
}