is_post_publicly_viewable example


    public function check_read_terms_permission_for_post( $post$request ) {
        // If the requested post isn't associated with this taxonomy, deny access.         if ( ! is_object_in_taxonomy( $post->post_type, $this->taxonomy ) ) {
            return false;
        }

        // Grant access if the post is publicly viewable.         if ( is_post_publicly_viewable( $post ) ) {
            return true;
        }

        // Otherwise grant access if the post is readable by the logged in user.         if ( current_user_can( 'read_post', $post->ID ) ) {
            return true;
        }

        // Otherwise, deny access.         return false;
    }

    

function get_oembed_response_data( $post$width ) {
    $post  = get_post( $post );
    $width = absint( $width );

    if ( ! $post ) {
        return false;
    }

    if ( ! is_post_publicly_viewable( $post ) ) {
        return false;
    }

    /** * Filters the allowed minimum and maximum widths for the oEmbed response. * * @since 4.4.0 * * @param array $min_max_width { * Minimum and maximum widths for the oEmbed response. * * @type int $min Minimum width. Default 200. * @type int $max Maximum width. Default 600. * } */

        if (
            // Private post statuses only redirect if the user can read them.             ! (
                $post_status_obj->private &&
                current_user_can( 'read_post', $redirect_obj->ID )
            ) &&
            // For other posts, only redirect if publicly viewable.             ! is_post_publicly_viewable( $redirect_obj )
        ) {
            $redirect_obj = false;
            $redirect_url = false;
        }
    }

    /** * Filters the canonical redirect URL. * * Returning false to this filter will cancel the redirect. * * @since 2.3.0 * * @param string $redirect_url The redirect URL. * @param string $requested_url The requested URL. */
Home | Imprint | This part of the site doesn't use cookies.