Created
January 20, 2018 12:17
-
-
Save hwkdev/4b6ffb03aeb877d32190aabe0f659469 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 | |
| // Post Type Subpages: Ajout permaliens sous le titre du Post dans l'Admin | |
| add_action('edit_form_after_title', 'hwk_ptsp_edit_after_title'); | |
| function hwk_ptsp_edit_after_title($post){ | |
| if(!$post_types = hwk_ptsp_get_post_types()) | |
| return; | |
| foreach($post_types as $post_type){ | |
| if(get_post_type() != $post_type['post_type']) | |
| continue; | |
| foreach($post_type['pages'] as $page){ | |
| if($page['primary']) | |
| continue; | |
| // Si la page a un paramètre Rewrite et qu'un Post Meta est défini avec un slug: Afficher l'URL | |
| if( hwk_ptsp_page_has_rewrite($page) && ($slug = get_post_meta($post->ID, $post_type['meta_prefix'] . $page['name'], true)) && !empty($slug) ){ | |
| ?> | |
| <div id="edit-slug-box"> | |
| <strong>Permalien <?php echo $page['title']; ?> :</strong> | |
| <a href="<?php echo hwk_ptsp_get_sub_permalink($post->ID, $page['name']); ?>"><?php echo hwk_ptsp_get_sub_permalink($post->ID, $page['name']); ?></a> | |
| </div> | |
| <?php | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment