dozent_post_class( string $class = '', null $post_id = null )


Parameters

$class

(string) (Optional)

Default value: ''

$post_id

(null) (Optional)

Default value: null


Return

(array) print post class


Source

File: includes/core-functions.php

	function dozent_post_class($class = '', $post_id = null)
	{

		$post = get_post($post_id);

		$classes = [];

		if ($class) {
			if (!is_array($class)) {
				$class = preg_split('#\s+#', $class);
			}
			$classes = array_map('esc_attr', $class);
		} else {
			// Ensure that we always coerce class to being an array.
			$class = [];
		}

		if (!$post) {
			return $classes;
		}

		$classes[] = 'post-' . $post->ID;
		if (!is_admin()) {
			$classes[] = $post->post_type;
		}
		$classes[] = 'type-' . $post->post_type;
		$classes[] = 'type-' . $post->post_type . '-' . $post->ID;
		$classes[] = 'status-' . $post->post_status;

		$classes = apply_filters('dozent_post_class', $classes);

		echo 'class="' . join(' ', $classes) . '"';

	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.