Function Reference: geodir_core_post_view_extra_class

Summary

Appends extra HTML classes to the post class.

Global Values

$post
(object) (required) The current post object.

Default: None

Package

GeoDirectory

Parameters

$class
(string) (required) The old class string.

Default: None
$all_postypes
(string|array) (required) The GD post types.

Default: None

Return Values

(string)
  • The modified post class.

Change Log

Since: 1.0.0

Source File

geodir_core_post_view_extra_class() is located in geodirectory-functions/template_functions.php [Line: 482]

Source Code

function geodir_core_post_view_extra_class($class, $all_postypes = '')
{
    global $post;

    if (!$all_postypes) {
        $all_postypes = geodir_get_posttypes();
    }

    $gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL;
    $gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL;
    $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL;

    if ($gdp_post_id && $gdp_post_type) {
        $append_class = 'gd-post-' . $gdp_post_type;
        $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : '';
        $class = $class != '' ? $class . ' ' . $append_class : $append_class;
    }

    return $class;
}