Ticket #323: 323.diff
| File 323.diff, 6.0 KB (added by , 12 years ago) |
|---|
-
content-reference.php
diff --git a/content-reference.php b/content-reference.php index 6b0030c..79b4728 100644
a b 50 50 <?php endif; ?> 51 51 */ ?> 52 52 53 <?php if ( show_usage_info() ) : ?> 54 <hr /> 55 <section class="usage"> 56 <article class="used-by"> 57 <h2><?php _e( 'Used by', 'wporg' ); ?></h2> 58 <ul> 59 <?php 60 $used_by = get_used_by(); 61 while ( $used_by->have_posts() ) : $used_by->the_post(); 62 ?> 63 <li> 64 <strong><?php echo esc_attr( get_source_file() ); ?>:</strong> 65 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 66 </li> 67 <?php endwhile; wp_reset_postdata(); ?> 68 </ul> 69 70 </article> 71 <article class="uses"> 72 <h2><?php _e( 'Uses', 'wporg' ); ?></h2> 73 <ul> 74 <?php 75 $uses = get_uses(); 76 while ( $uses->have_posts() ) : $uses->the_post() 77 ?> 78 <li> 79 <strong><?php echo esc_attr( get_source_file() ); ?>:</strong> 80 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 81 </li> 82 <?php endwhile; wp_reset_postdata(); ?> 83 </ul> 84 </article> 85 </section> 86 <?php endif; ?> 87 53 88 <?php 54 89 ob_start(); 55 90 the_content(); -
inc/template-tags.php
diff --git a/inc/.DS_Store b/inc/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/inc/.DS_Store and /dev/null differ diff --git a/inc/template-tags.php b/inc/template-tags.php index 1212318..2a30a94 100755
a b function compare_objects_by_name( $a, $b ) { 700 700 return strcmp( $a->post_name, $b->post_name ); 701 701 } 702 702 703 function show_usage_info() { 704 $p2p_enabled = function_exists( 'p2p_register_connection_type' ); 705 706 return $p2p_enabled && post_type_has_usage_info( get_post_type() ); 707 } 708 709 /** 710 * Does the post type support usage information? 711 * 712 * @param string $post_type Optional. The post type name. If blank, assumes current post type. 713 * 714 * @return boolean 715 */ 716 function post_type_has_usage_info( $post_type = null ) { 717 $post_type = $post_type ? $post_type : get_post_type(); 718 $post_types_with_usage = array( 'wp-parser-function', 'wp-parser-method', 'wp-parser-hook' ); 719 720 return in_array( $post_type, $post_types_with_usage ); 721 } 722 723 /** 724 * Retrieve a WP_Query object for the posts that the current post uses 725 * 726 * @return WP_Query A WP_Query object for the posts the current post uses 727 */ 728 function get_uses() { 729 $post = get_post(); 730 731 if ( 'wp-parser-function' === get_post_type() ) { 732 $connection_types = array( 'functions_to_functions', 'functions_to_methods', 'functions_to_hooks' ); 733 } else { 734 $connection_types = array( 'methods_to_functions', 'methods_to_methods', 'methods_to_hooks' ); 735 } 736 737 $connected = new \WP_Query( array( 738 'post_type' => array( 'wp-parser-function', 'wp-parser-method', 'wp-parser-hook' ), 739 'connected_type' => $connection_types, 740 'connected_direction' => array( 'from', 'from', 'from' ), 741 'connected_items' => get_queried_object(), 742 'nopaging' => true, 743 ) ); 744 745 return $connected; 746 } 747 748 function get_used_by( $post_id = null ) { 749 750 if ( empty( $post_id ) ) { 751 $post_id = get_the_ID(); 752 } 753 754 switch ( get_post_type() ) { 755 756 case 'wp-parser-function': 757 $connection_types = array( 'functions_to_functions', 'methods_to_functions' ); 758 break; 759 760 case 'wp-parser-method': 761 $connection_types = array( 'functions_to_methods', 'methods_to_methods', ); 762 break; 763 764 case 'wp-parser-hook': 765 $connection_types = array( 'functions_to_hooks', 'methods_to_hooks' ); 766 break; 767 } 768 769 $connected = new \WP_Query( array( 770 'post_type' => array( 'wp-parser-function', 'wp-parser-method' ), 771 'connected_type' => $connection_types, 772 'connected_direction' => array( 'to', 'to' ), 773 'connected_items' => $post_id, 774 'nopaging' => true, 775 ) ); 776 777 return $connected; 778 } 779 703 780 /** 704 781 * Does the post type have source code? 705 782 * -
new file scss/_mixins.scss
diff --git a/scss/_mixins.scss b/scss/_mixins.scss new file mode 100644 index 0000000..62aae3c
- + 1 @mixin clearfix { 2 &:before, 3 &:after { 4 content: " "; 5 display: table; 6 } 7 8 &:after { 9 clear: both; 10 } 11 } 12 No newline at end of file -
scss/main.scss
diff --git a/scss/main.scss b/scss/main.scss index 897267b..cb9c7f5 100644
a b 1 1 @import "reset"; 2 2 @import "global"; 3 3 4 @import "mixins"; 5 4 6 .home .devhub-wrap { 5 7 #content { 6 8 padding: 0; … … 966 968 } 967 969 } 968 970 971 /* = Usage 972 ----------------------------------------------- */ 973 .usage { 974 @include clearfix; 975 976 article { 977 float: left; 978 width: 50%; 979 } 980 981 .used-by { 982 padding-right: 30px; 983 } 984 985 .uses { 986 padding-left: 30px; 987 } 988 } 989 990 969 991 .source-content { 970 992 overflow: auto; 971 993 } … … 1313 1335 .two-columns .box { 1314 1336 width: 99%; 1315 1337 } 1338 1339 .usage { 1340 article { 1341 width: 100%; 1342 } 1343 } 1316 1344 } 1317 1345 } 1346 No newline at end of file -
stylesheets/main.css
diff --git a/stylesheets/main.css b/stylesheets/main.css index db6736e..f0b6d61 100644
a b input { 298 298 /* 299 299 * section styles 300 300 */ 301 /* = Usage 302 ----------------------------------------------- */ 301 303 /* Comments */ 302 304 /* 303 305 * Content … … input { 1157 1159 .devhub-wrap .single .wp-parser-class, .devhub-wrap .single .wp-parser-function, .devhub-wrap .single .wp-parser-hook, .devhub-wrap .single .wp-parser-method { 1158 1160 border-bottom-style: none; 1159 1161 } 1162 .devhub-wrap .usage:before, .devhub-wrap .usage:after { 1163 content: " "; 1164 display: table; 1165 } 1166 .devhub-wrap .usage:after { 1167 clear: both; 1168 } 1169 .devhub-wrap .usage article { 1170 float: left; 1171 width: 50%; 1172 } 1173 .devhub-wrap .usage .used-by { 1174 padding-right: 30px; 1175 } 1176 .devhub-wrap .usage .uses { 1177 padding-left: 30px; 1178 } 1160 1179 .devhub-wrap .source-content { 1161 1180 overflow: auto; 1162 1181 } … … input { 1423 1442 .devhub-wrap .two-columns .box { 1424 1443 width: 99%; 1425 1444 } 1445 .devhub-wrap .usage article { 1446 width: 100%; 1447 } 1426 1448 }