Tribe__Admin__Help_Page::get_content_html( string|array $mixed = '' )

Parses the help text from an Array to the final HTML.

It is the responsibility of code calling this function to ensure proper escaping within any HTML.


Parameters #

$mixed

(string|array) (Optional) The mixed value to create the HTML from

Default value: ''


Top ↑

Return #

(string)


Top ↑

Source #

File: src/Tribe/Admin/Help_Page.php

	public function get_content_html( $mixed = '' ) {
		// If it's an StdObj or String it will be converted
		$mixed = (array) $mixed;

		// Loop to start the HTML
		foreach ( $mixed as &$line ) {
			// If we have content we use that
			if ( isset( $line->content ) ) {
				$line = $line->content;
			}

			if ( is_string( $line ) ) {
				continue;
			} elseif ( is_array( $line ) ) {
				// Allow the developer to pass some configuration
				if ( empty( $line['type'] ) ) {
					$line['type'] = 'ul';
				}

				$text = '<' . $line['type'] . '>' . "\n";
				foreach ( $line as $key => $item ) {
					// Don't add non-numeric items (a.k.a.: configuration)
					if ( ! is_numeric( $key ) ) {
						continue;
					}

					// Only add List Item if is a UL or OL
					if ( in_array( $line['type'], array( 'ul', 'ol' ) ) ) {
						$text .= '<li>' . "\n";
					}

					$text .= $this->get_content_html( $item );

					if ( in_array( $line['type'], array( 'ul', 'ol' ) ) ) {
						$text .= '</li>' . "\n";
					}
				}
				$text .= '</' . $line['type'] . '>' . "\n";

				// Create the list as html instead of array
				$line = $text;
			}
		}

		return wpautop( implode( "\n\n", $mixed ) );
	}

Top ↑

Changelog #

Changelog
Version Description
4.0 Introduced.