Tribe__Admin__Help_Page::get_sections( boolean $print = true )
Based on an Array of sections it render the Help Page contents
Contents
Parameters
-
(boolean) (Optional) Return or Print the HTML after.
Default value: true
Return
(void|string)
Source
File: src/Tribe/Admin/Help_Page.php
public function get_sections( $print = true ) {
/**
* Allow third-party sections here
*
* @var Tribe__Admin__Help_Page
*/
do_action( 'tribe_help_pre_get_sections', $this );
/**
* Allow developers to filter all the sections at once
* NOTE: You should be using `tribe_help_add_sections` to add new sections or content
*
* @var array
*/
$sections = apply_filters( 'tribe_help_sections', $this->sections );
if ( ! is_array( $sections ) || empty( $sections ) ) {
return false;
}
// Sort by Priority
uasort( $sections, array( $this, 'by_priority' ) );
$html = array();
foreach ( $sections as $index => $section ) {
$section = (object) $section;
// If it has no ID or Content, skip
if ( empty( $section->id ) || empty( $section->content ) ) {
continue;
}
// Set a Default type
if ( empty( $section->type ) ) {
$section->type = 'default';
}
/**
* Creates a way to filter a specific section based on the ID
*
* @var object
*/
$section = apply_filters( 'tribe_help_section_' . $section->id, $section, $this );
// Sort by Priority
uasort( $section->content, array( $this, 'by_priority' ) );
$html[ $section->id . '-start' ] = '<div id="tribe-' . sanitize_html_class( $section->id ) . '" class="tribe-help-section clearfix tribe-section-type-' . sanitize_html_class( $section->type ) . '">';
if ( ! empty( $section->title ) ) {
$html[ $section->id . '-title' ] = '<h3 class="tribe-help-title">' . esc_html__( $section->title ) . '</h3>';
}
$html[ $section->id . '-content' ] = $this->get_content_html( $section->content );
$html[ $section->id . '-end' ] = '</div>';
}
/**
* Creates a way for developers to hook to the final HTML
* @var array $html
* @var array $sections
*/
$html = apply_filters( 'tribe_help_sections_html', $html, $sections );
if ( true === $print ) {
echo implode( "\n", $html );
} else {
return $html;
}
}
Changelog
| Version | Description |
|---|---|
| 4.0 | Introduced. |