Created
November 2, 2022 15:54
-
-
Save kylephillips/28e2dd35b2923a672f5122fff93aeaad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the link post type to the query args passed to the listing query | |
*/ | |
add_filter('nestedpages_page_listing', 'nestedpages_add_links_to_listing', 10, 2); | |
function nestedpages_add_links_to_listing($query_args, $post_type) | |
{ | |
if ( $post_type->name == 'custom-post-type' ) $query_args['post_type'][] = 'np-redirect'; | |
return $query_args; | |
} | |
/** | |
* Add the link interface to the custom post type | |
*/ | |
add_filter('nestedpages_show_links', 'nestedpages_add_links_interface', 10, 4); | |
function nestedpages_add_links_interface($show_links, $post_type, $user, $listing) | |
{ | |
$show_links = ( $user->canPublish($post_type->name) | |
&& ( $post_type->name == 'page' || $post_type->name == 'custom-post-type' ) // Custom post type added here | |
&& !$listing->isSearch() | |
&& !$listing->isOrdered($post_type->name) | |
&& !$listing->settings->menusDisabled() | |
&& !$listing->integrations->plugins->wpml->installed ) | |
? true : false; | |
return $show_links; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment