Skip to content

Commit 7c038fb

Browse files
Hide metabox from the unpublicly post types (#107)
1 parent 9929891 commit 7c038fb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

includes/class-custom-permalinks-form.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ public function init() {
7979
* return bool false Whether to show Custom Permalink form or not.
8080
*/
8181
private function exclude_custom_permalinks( $post ) {
82-
$args = array(
83-
'public' => true,
84-
);
8582
$exclude_post_types = apply_filters(
8683
'custom_permalinks_exclude_post_type',
8784
$post->post_type
@@ -96,7 +93,22 @@ private function exclude_custom_permalinks( $post ) {
9693
'custom_permalinks_exclude_posts',
9794
$post
9895
);
99-
$public_post_types = get_post_types( $args, 'objects' );
96+
$post_types = get_post_types(
97+
array(
98+
'public' => true,
99+
),
100+
'objects'
101+
);
102+
$public_post_types = array();
103+
104+
foreach ( $post_types as $post_type_name => $single ) {
105+
// Check conditions for accessible single post URLs.
106+
if ( 'page' === $post_type_name || 'post' === $post_type_name ) {
107+
$public_post_types[ $post_type_name ] = $single;
108+
} elseif ( $single->publicly_queryable && $single->rewrite ) {
109+
$public_post_types[ $post_type_name ] = $single;
110+
}
111+
}
100112

101113
if ( isset( $this->permalink_metabox ) && 1 === $this->permalink_metabox ) {
102114
$check_availability = true;

0 commit comments

Comments
 (0)