shouldRender() ) { //Should this even be allowed? echo sprintf( '', esc_html($section->getTitle()), esc_html($section->getId()) ); } echo '
'; $this->renderSectionHeading($section); $description = $section->getDescription($context); if ( !empty($description) ) { //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML intentionally allowed. echo "\n", '

', $description, '

'; } //Render each section as a table. echo ''; $this->renderSectionChildren($section, $context); echo '
'; echo '
'; } protected function renderSectionHeading($section, $headingLevel = 2) { $title = $section->getTitle(); if ( !empty($title) ) { echo sprintf('', (int)$headingLevel); $this->renderSectionTitleContent($section); echo sprintf('', (int)$headingLevel); } } protected function renderChildSection(Section $section, EvaluationContext $context) { $this->sectionNestingLevel++; if ( $section->hasTitle() ) { $headingLevel = min(6, 2 + $this->sectionNestingLevel); echo ''; $this->renderSectionHeading($section, $headingLevel); echo ''; } $this->renderSectionChildren($section, $context); $this->sectionNestingLevel--; } protected function renderControlGroup(ControlGroup $group, EvaluationContext $context) { $isStacked = $group->isStacked(); $classes = $group->getClasses(); $titleDone = false; /* * - Render top-level groups as table rows. Optionally, their contents * can be wrapped in a fieldset element. * - Render nested groups as either fieldset elements or a flat sequence * of controls. */ $isFieldset = $group->wantsFieldset(); if ( $isFieldset === null ) { $isFieldset = $this->isInsideRow; } $renderAsTableRow = !$this->isInsideRow; $wasInsideRow = $this->isInsideRow; if ( $renderAsTableRow ) { $this->isInsideRow = true; printf('', esc_attr($group->getHtmlIdBase($context))); printf( '', esc_attr($group->hasTooltip() ? 'ame-customizable-cg-has-tooltip' : '') ); $this->renderGroupTitleContent($group); $titleDone = true; echo ''; echo ''; } if ( $isFieldset ) { HtmlHelper::outputTag('fieldset', [ 'disabled' => !$group->isEnabled($context), 'class' => $classes, ]); } if ( !$renderAsTableRow && !$titleDone ) { $this->renderGroupTitleContent($group); } $childContext = $context->withAttributes([ self::IS_STACKED_ATTRIBUTE => $isStacked, ]); $this->renderGroupChildren($group, $childContext); if ( $isFieldset ) { echo ''; } if ( $renderAsTableRow ) { echo ''; echo ''; $this->isInsideRow = $wasInsideRow; } } public function renderControl(Control $control, EvaluationContext $context) { if ( !$control->shouldRender() ) { //This should really never happen. echo ''; return; } $addLineBreaks = ($context->getAttribute(self::IS_STACKED_ATTRIBUTE) && !$control->declinesExternalLineBreaks()); if ( $addLineBreaks ) { echo '

'; } parent::renderControl($control, $context); if ( $addLineBreaks ) { echo '

'; } } public function enqueueDependencies(string $containerSelector = '') { static $done = false; if ( $done ) { return; } $done = true; parent::enqueueDependencies($containerSelector); wp_enqueue_style( 'ame-form-table-renderer', plugins_url('assets/form-table.css', AME_CUSTOMIZABLE_BASE_FILE), array(), '20221129' ); } }