Function Reference: geodir_add_post_status_author_page

Summary

Adds post status on author page when the author is current user.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None
$post
(object) (required) The current post object.

Default: None

Package

GeoDirectory

Change Log

Since: 1.0.0

Filters

‘geodir_post_status_is_author_page’ [Line: 2615]

‘geodir_filter_status_text_on_author_page’ [Line: 2643]

Source File

geodir_add_post_status_author_page() is located in geodirectory_hooks_actions.php [Line: 2608]

Source Code

function geodir_add_post_status_author_page()
{
    global $wpdb, $post;

    $html = '';
    if (get_current_user_id()) {

        $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author'));
        if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {

            // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
            $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
            $status = "(";
            $status_icon = '';
            if ($real_status == 'publish') {
                $status .= __('Published', 'geodirectory');
            }elseif ($real_status == 'pending') {
                $status .= __('Awaiting Review', 'geodirectory');
            } else {
                $status .= __('Not published', 'geodirectory');
                $status_icon = '';
            }
            $status .= ")";

            $html = '' . $status_icon . ' ' . __('Status: ', 'geodirectory') . '' . $status . '';
        }
    }

    if ($html != '') {
        /**
         * Filter the post status text on the author page.
         *
         * @since 1.0.0
         * @param string $html The HTML of the status.
         */
        echo apply_filters('geodir_filter_status_text_on_author_page', $html);
    }


}