shouldRender() ) { //Should this even be allowed? echo sprintf( '', esc_html($section->getTitle()), esc_html($section->getId()) ); } echo '
'; $this->renderSectionHeading($section); $description = $section->getDescription(); 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); 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) { $this->sectionNestingLevel++; if ( $section->hasTitle() ) { $headingLevel = min(6, 2 + $this->sectionNestingLevel); echo ''; $this->renderSectionHeading($section, $headingLevel); echo ''; } $this->renderSectionChildren($section); $this->sectionNestingLevel--; } protected function renderControlGroup($group) { $isStacked = $group->isStacked(); /* * - 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->getId())); printf( '', esc_attr($group->hasTooltip() ? 'ame-customizable-cg-has-tooltip' : '') ); $this->renderGroupTitleContent($group); echo ''; echo ''; } if ( $isFieldset ) { /** @noinspection HtmlUnknownAttribute */ printf('
', $group->isEnabled() ? '' : 'disabled'); } $this->renderGroupChildren($group, $isStacked); if ( $isFieldset ) { echo '
'; } if ( $renderAsTableRow ) { echo ''; echo ''; $this->isInsideRow = $wasInsideRow; } } public function renderControl($control, $parentContext = null) { if ( !$control->shouldRender() ) { //This should really never happen. echo ''; return; } $addLineBreaks = ($parentContext && !$control->declinesExternalLineBreaks()); if ( $addLineBreaks ) { echo '

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

'; } } public function enqueueDependencies($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' ); } }