Function Reference: geodir_fix_pending_listing_post_name

Summary

Set the post name for the pending listing.

Parameters

$data
(array) (required) An array of slashed post data.

Default: None
$postarr
(array) (required) An array of sanitized, but otherwise unmodified post data.

Default: None

Return Values

(array)
  • Filtered post data.

Change Log

Since: 1.6.22

1.6.23 Fix post name for autosaved listing from backend.

Source File

geodir_fix_pending_listing_post_name() is located in geodirectory-functions/post_functions.php [Line: 3286]

Source Code

function geodir_fix_pending_listing_post_name( $data, $postarr ) {
    // Dont' update post name for autosaves
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        return $data;
    }

    if ( !empty( $data['post_name'] ) || empty( $data['post_status'] ) || empty( $data['post_type'] ) || empty( $data['post_title'] ) ) {
        return $data;
    }

    if ( ( 'draft' == $data['post_status'] || 'pending' == $data['post_status'] ) && in_array( $data['post_type'], geodir_get_posttypes() ) ) {
        $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'] ), ( !empty( $postarr['ID'] ) ? $postarr['ID'] : 0 ), '', $data['post_type'], $data['post_parent'] );
    }

    return $data;
}