@@ 637-700 (lines=64) @@ | ||
634 | } |
|
635 | ||
636 | ||
637 | function acf_get_pretty_post_types( $post_types = array() ) { |
|
638 | ||
639 | // get post types |
|
640 | if( empty($post_types) ) { |
|
641 | ||
642 | // get all custom post types |
|
643 | $post_types = acf_get_post_types(); |
|
644 | ||
645 | } |
|
646 | ||
647 | ||
648 | // get labels |
|
649 | $ref = array(); |
|
650 | $r = array(); |
|
651 | ||
652 | foreach( $post_types as $post_type ) { |
|
653 | ||
654 | // vars |
|
655 | $label = $post_type; |
|
656 | ||
657 | ||
658 | // check that object exists (case exists when importing field group from another install and post type does not exist) |
|
659 | if( post_type_exists($post_type) ) { |
|
660 | ||
661 | $obj = get_post_type_object($post_type); |
|
662 | $label = $obj->labels->singular_name; |
|
663 | ||
664 | } |
|
665 | ||
666 | ||
667 | // append to r |
|
668 | $r[ $post_type ] = $label; |
|
669 | ||
670 | ||
671 | // increase counter |
|
672 | if( !isset($ref[ $label ]) ) { |
|
673 | ||
674 | $ref[ $label ] = 0; |
|
675 | ||
676 | } |
|
677 | ||
678 | $ref[ $label ]++; |
|
679 | } |
|
680 | ||
681 | ||
682 | // get slugs |
|
683 | foreach( array_keys($r) as $i ) { |
|
684 | ||
685 | // vars |
|
686 | $post_type = $r[ $i ]; |
|
687 | ||
688 | if( $ref[ $post_type ] > 1 ) { |
|
689 | ||
690 | $r[ $i ] .= ' (' . $i . ')'; |
|
691 | ||
692 | } |
|
693 | ||
694 | } |
|
695 | ||
696 | ||
697 | // return |
|
698 | return $r; |
|
699 | ||
700 | } |
|
701 | ||
702 | ||
703 | /* |
|
@@ 1012-1068 (lines=57) @@ | ||
1009 | } |
|
1010 | ||
1011 | ||
1012 | function acf_get_pretty_taxonomies( $taxonomies = array() ) { |
|
1013 | ||
1014 | // get post types |
|
1015 | if( empty($taxonomies) ) { |
|
1016 | ||
1017 | // get all custom post types |
|
1018 | $taxonomies = acf_get_taxonomies(); |
|
1019 | ||
1020 | } |
|
1021 | ||
1022 | ||
1023 | // get labels |
|
1024 | $ref = array(); |
|
1025 | $r = array(); |
|
1026 | ||
1027 | foreach( array_keys($taxonomies) as $i ) { |
|
1028 | ||
1029 | // vars |
|
1030 | $taxonomy = acf_extract_var( $taxonomies, $i); |
|
1031 | $obj = get_taxonomy( $taxonomy ); |
|
1032 | $name = $obj->labels->singular_name; |
|
1033 | ||
1034 | ||
1035 | // append to r |
|
1036 | $r[ $taxonomy ] = $name; |
|
1037 | ||
1038 | ||
1039 | // increase counter |
|
1040 | if( !isset($ref[ $name ]) ) { |
|
1041 | ||
1042 | $ref[ $name ] = 0; |
|
1043 | ||
1044 | } |
|
1045 | ||
1046 | $ref[ $name ]++; |
|
1047 | } |
|
1048 | ||
1049 | ||
1050 | // get slugs |
|
1051 | foreach( array_keys($r) as $i ) { |
|
1052 | ||
1053 | // vars |
|
1054 | $taxonomy = $r[ $i ]; |
|
1055 | ||
1056 | if( $ref[ $taxonomy ] > 1 ) { |
|
1057 | ||
1058 | $r[ $i ] .= ' (' . $i . ')'; |
|
1059 | ||
1060 | } |
|
1061 | ||
1062 | } |
|
1063 | ||
1064 | ||
1065 | // return |
|
1066 | return $r; |
|
1067 | ||
1068 | } |
|
1069 | ||
1070 | ||
1071 | /* |