getTitle() ?: 'Root', $structure->getAsSections(), ['id' => 'structure-root'] ); $this->renderSection($rootSection); } protected function renderPendingSections() { while (!empty($this->pendingSections)) { $section = array_shift($this->pendingSections); $this->renderSection($section); } } public function renderSection($section) { echo HtmlHelper::tag('ul', [ 'class' => 'ame-ac-section', 'id' => $this->getSectionElementId($section), ]); ?>
  • getTitle()); ?>

  • renderSectionChildren($section); echo ''; $this->renderPendingSections(); } protected function renderChildSection($section) { if ( $section->hasChildren() ) { $this->pendingSections[] = $section; } echo HtmlHelper::tag('li', [ 'class' => 'ame-ac-section-link', 'data-target-id' => $this->getSectionElementId($section), ]); printf( '

    %s

    ', esc_html($section->getTitle()) ); echo ''; } protected function renderControlGroup($group) { $title = $group->getTitle(); if ( !empty($title) ) { echo '
  • '; echo '

    '; echo esc_html($title); echo '

    '; echo '
  • '; } $this->renderGroupChildren($group); } protected function renderUngroupedControl($control) { $this->renderControl($control); } public function renderControl($control, $parentContext = null) { $settings = $control->getSettings(); $settingIds = array_map(function ($setting) { return $setting->getId(); }, $settings); //The collection of settings IDs should be an associative array. If it's not, //assign the first setting to the "default" key. $isAssociative = false; foreach ($settingIds as $key => $value) { if ( is_string($key) ) { $isAssociative = true; break; } } if ( !$isAssociative ) { $firstId = array_shift($settingIds); $settingIds['default'] = $firstId; } echo HtmlHelper::tag('li', [ 'class' => 'ame-ac-control', 'data-ac-setting-ids' => !empty($settingIds) ? wp_json_encode($settingIds) : null, 'data-ac-control-type' => $control->getType(), ]); if ( !$control->includesOwnLabel() ) { $this->renderControlLabel($control); } parent::renderControl($control, $parentContext); echo ''; } public function renderTooltipTrigger(Tooltip $tooltip) { // TODO: Implement renderTooltipTrigger() method. echo '[tooltip here]'; } protected function getSectionElementId($section) { return 'ame-ac-section-' . $section->getId(); } /** * @param \YahnisElsts\AdminMenuEditor\Customizable\Controls\Control $control * @return void */ protected function renderControlLabel($control) { $label = $control->getLabel(); if ( empty($label) ) { return; } $labelForId = $control->getLabelTargetId(); if ( $control->supportsLabelAssociation() && !empty($labelForId) ) { printf( '', esc_attr($labelForId), esc_html($label) ); } else { printf( '%s', esc_html($label) ); } } }