Ticket #1802: 1802.2.diff
File 1802.2.diff, 21.0 KB (added by , 8 years ago) |
---|
-
content-reference.php
14 14 15 15 <?php if ( is_single() ) : ?> 16 16 17 <section class="description">18 <?php echo get_description(); ?>19 </section>20 21 17 <?php 22 $return = get_return(); 23 if ( ! empty( $return ) ) : 24 ?> 25 <section class="return"><p><strong><?php _e( 'Return:', 'wporg' ); ?></strong> <?php echo $return; ?></p></section> 26 <?php endif; ?> 18 $content = get_reference_template_parts(); 27 19 28 <?php 29 $source_file = get_source_file(); 30 if ( ! empty( $source_file ) ) : 31 ?> 32 <section class="source"> 33 <p> 34 <strong><?php _e( 'Source file:', 'wporg' ); ?></strong> 35 <a href="<?php echo get_source_file_archive_link( $source_file ); ?>"><?php echo esc_html( $source_file ); ?></a> 36 </p> 37 <?php if ( post_type_has_source_code() ) { ?> 38 <p> 39 <a href="#source-code"><?php _e( 'View source', 'wporg' ); ?></a> 40 </p> 41 <?php } else { ?> 42 <p> 43 <a href="<?php echo get_source_file_link(); ?>"><?php _e( 'View on Trac', 'wporg' ); ?></a> 44 </p> 45 <?php } ?> 46 </section> 47 <?php endif; ?> 20 // If the Handbook TOC is available, use it. 21 if ( class_exists( 'WPorg_Handbook_TOC' ) ) : 22 $TOC = new \WPorg_Handbook_TOC( get_parsed_post_types(), array( 23 'header_text' => __( 'Table of Contents', 'wporg' ) 24 ) ); 48 25 49 <?php if ( $params = get_params() ) : ?> 50 <hr/> 51 <section class="parameters"> 52 <h2><?php _e( 'Parameters', 'wporg' ); ?></h2> 53 <dl> 54 <?php foreach ( $params as $param ) : ?> 55 <?php if ( ! empty( $param['variable'] ) ) : ?> 56 <dt><?php echo esc_html( $param['variable'] ); ?></dt> 57 <?php endif; ?> 58 <dd> 59 <p class="desc"> 60 <?php if ( ! empty( $param['types'] ) ) : ?> 61 <span class="type"><?php printf( __( '(%s)', 'wporg' ), wp_kses_post( $param['types'] ) ); ?></span> 62 <?php endif; ?> 63 <?php if ( ! empty( $param['required'] ) && 'wp-parser-hook' !== get_post_type() ) : ?> 64 <span class="required"><?php printf( __( '(%s)', 'wporg' ), esc_html( $param['required'] ) ); ?></span> 65 <?php endif; ?> 66 <?php if ( ! empty( $param['content'] ) ) : ?> 67 <span class="description"><?php echo wp_kses_post( $param['content'] ); ?></span> 68 <?php endif; ?> 69 </p> 70 <?php if ( ! empty( $param['default'] ) ) : ?> 71 <p class="default"><?php _e( 'Default value:', 'wporg' );?> <?php echo htmlentities( $param['default'] ); ?></p> 72 <?php endif; ?> 73 </dd> 74 <?php endforeach; ?> 75 </dl> 76 </section> 77 <?php endif; ?> 78 79 <?php 80 $explanation = get_explanation_field( 'post_content', get_the_ID() ); 81 if ( $explanation ) : 82 ?> 83 <hr/> 84 <section class="explanation"> 85 <h2><?php _e( 'More Information', 'wporg' ); ?></h2> 86 87 <?php 88 // Output the explanation. Passed through 'the_content' on retrieval, thus no escaping. 89 echo $explanation; 90 ?> 91 </section> 92 <?php endif; ?> 93 94 <?php /* 95 <?php if ( $arguments = get_arguments() ) : //todo: output arg data ?> 96 <hr/> 97 <section class="arguments"> 98 <h2><?php _e( 'Arguments', 'wporg' ); ?></h2> 99 </section> 100 <?php endif; ?> 101 <hr/> 102 <section class="learn-more"> 103 <h2><?php _e( 'Learn More', 'wporg' ); ?></h2> 104 </section> 105 */ ?> 106 107 <?php if ( 'wp-parser-class' === get_post_type() ) : 108 if ( $children = get_children( array( 'post_parent' => get_the_ID(), 'post_status' => 'publish' ) ) ) : 109 usort( $children, __NAMESPACE__ . '\\compare_objects_by_name' ); 26 add_filter( 'the_content', array( $TOC, 'add_toc' ) ); 27 $content = apply_filters( 'the_content', $content ); 28 remove_filter( 'the_content', array( $TOC, 'add_toc' ) ); 29 endif; 110 30 ?> 111 <hr/>112 <section class="class-methods">113 <h2><?php _e( 'Methods', 'wporg' ); ?></h2>114 <ul>115 <?php foreach ( $children as $child ) : ?>116 <li><a href="<?php echo get_permalink( $child->ID ); ?>">117 <?php118 $title = get_the_title( $child );119 $pos = ( $i = strrpos( $title, ':' ) ) ? $i + 1 : 0;120 echo substr( $title, $pos );121 ?></a>122 <?php if ( $excerpt = apply_filters( 'get_the_excerpt', $child->post_excerpt ) ) {123 echo '— ' . sanitize_text_field( $excerpt );124 } ?>125 <?php if ( is_deprecated( $child->ID ) ) {126 echo '— <span class="deprecated-method">' . __( 'deprecated', 'wporg' ) . '</span>';127 } ?>128 </li>129 <?php endforeach; ?>130 </ul>131 </section>132 <?php endif;133 endif; ?>134 31 135 <?php if ( show_usage_info() ) : ?> 136 <hr id="usage" /> 137 <section class="usage"> 138 <article class="used-by"> 139 <h2><?php _e( 'Used by', 'wporg' ); ?></h2> 140 <ul> 141 <?php 142 $used_by = get_used_by(); 143 $used_by_to_show = 5; 144 while ( $used_by->have_posts() ) : $used_by->the_post(); 145 ?> 146 <li> 147 <span><?php echo esc_attr( get_source_file() ); ?>:</span> 148 <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( 'wp-parser-hook' !== get_post_type() ) : ?>()<?php endif; ?></a> 149 </li> 150 <?php endwhile; wp_reset_postdata(); ?> 151 <?php if ( $used_by->post_count > $used_by_to_show ) : ?> 152 <a href="#" class="show-more"><?php 153 /* translators: %d: remaining 'used by' count */ 154 printf( _n( 'Show %d more used by', 'Show %d more used by', $used_by->post_count - $used_by_to_show, 'wporg' ), 155 number_format_i18n( $used_by->post_count - $used_by_to_show ) 156 ); 157 ?></a> 158 <a href="#" class="hide-more"><?php _e( 'Hide more used by', 'wporg' ); ?></a> 159 <?php endif; ?> 160 </ul> 161 </article> 162 <?php if ( post_type_has_uses_info() ) : ?> 163 <article class="uses"> 164 <h2><?php _e( 'Uses', 'wporg' ); ?></h2> 165 <ul> 166 <?php 167 $uses = get_uses(); 168 $uses_to_show = 5; 169 while ( $uses->have_posts() ) : $uses->the_post() 170 ?> 171 <li> 172 <span><?php echo esc_attr( get_source_file() ); ?>:</span> 173 <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( 'wp-parser-hook' !== get_post_type() ) : ?>()<?php endif; ?></a> 174 </li> 175 <?php endwhile; wp_reset_postdata(); ?> 176 <?php if ( $uses->post_count > $uses_to_show ) : ?> 177 <a href="#" class="show-more"><?php 178 /* translators: %d: remaining 'uses' count */ 179 printf( _n( 'Show %d more use', 'Show %d more uses', $uses->post_count - $uses_to_show, 'wporg' ), 180 number_format_i18n( $uses->post_count - $uses_to_show ) 181 ); 182 ?></a> 183 <a href="#" class="hide-more"><?php _e( 'Hide more uses', 'wporg' ); ?></a> 184 <?php endif; ?> 185 </ul> 186 </article> 187 <?php endif; ?> 188 </section> 189 <?php endif; ?> 32 <?php echo $content; ?> 190 33 191 <?php if ( post_type_has_source_code() ) : ?>192 <hr />193 <a id="source-code"></a>194 <section class="source-content">195 <h2><?php _e( 'Source', 'wporg' ); ?></h2>196 <div class="source-code-container">197 <pre class="brush: php; toolbar: false; first-line: <?php echo esc_attr( get_post_meta( get_the_ID(), '_wp-parser_line_num', true ) ); ?>"><?php echo htmlentities( get_source_code() ); ?></pre>198 </div>199 <p class="source-code-links">200 <span>201 <a href="#" class="show-complete-source"><?php _e( 'Expand full source code', 'wporg' ); ?></a>202 <a href="#" class="less-complete-source"><?php _e( 'Collapse full source code', 'wporg' ); ?></a>203 </span>204 <span><a href="<?php echo get_source_file_link(); ?>"><?php _e( 'View on Trac', 'wporg' ); ?></a></span>205 </p>206 </section>207 <?php endif; ?>208 209 <?php210 $changelog_data = get_changelog_data();211 if ( ! empty( $changelog_data ) ) :212 ?>213 <hr/>214 <section class="changelog">215 <h2><?php _e( 'Changelog', 'wporg' ); ?></h2>216 <ul>217 <?php foreach ( $changelog_data as $version => $data ) : ?>218 <li>219 <strong><?php _e( 'Since:', 'wporg' ); ?></strong>220 <?php printf(221 /* translators: %s: WordPress version */222 __( 'WordPress %s', 'wporg' ),223 sprintf( '<a href="%1$s">%2$s</a>', esc_url( $data['since_url'] ), esc_html( $version ) )224 ); ?>225 <?php echo $data['description']; // escaped in get_changelog_data() ?>226 </li>227 <?php endforeach; ?>228 </ul>229 </section>230 <?php endif; ?>231 232 <?php if ( comments_open() || '0' != get_comments_number() ) : ?>233 <hr/>234 <section class="user-notes">235 <h2><?php _e( 'User Contributed Notes', 'wporg' ); ?></h2>236 <?php comments_template(); /* TODO: add '/user-notes.php' */ ?>237 </section>238 <?php endif; ?>239 240 34 <?php endif; ?> 241 35 242 36 </article> -
inc/template-tags.php
1320 1320 1321 1321 $post_field = get_post_field( $field, $explanation, $context ); 1322 1322 1323 // If retrieving the explanation content for display, add the TOC if available. 1324 if ( 'post_content' === $field && 'display' === $context ) { 1325 if ( class_exists( 'WPorg_Handbook_TOC' ) ) : 1326 $TOC = new \WPorg_Handbook_TOC( get_parsed_post_types() ); 1327 1328 add_filter( 'the_content', array( $TOC, 'add_toc' ) ); 1329 $post_field = apply_filters( 'the_content', apply_filters( 'get_the_content', $post_field ) ); 1330 remove_filter( 'the_content', array( $TOC, 'add_toc' ) ); 1331 else : 1332 $post_field = apply_filters( 'the_content', apply_filters( 'get_the_content', $post_field ) ); 1333 endif; 1334 } 1335 1336 return $post_field; 1323 return apply_filters( 'the_content', apply_filters( 'get_the_content', $post_field ) ); 1337 1324 } 1338 1325 1339 1326 /** … … 1439 1426 1440 1427 echo $form; 1441 1428 } 1429 1430 /** 1431 * Retrieves all content for reference template parts. 1432 * 1433 * @return string Template part markup retrieved via output buffering. 1434 */ 1435 function get_reference_template_parts() { 1436 $templates = array( 1437 'description', 1438 'params', 1439 'return', 1440 'source', 1441 'changelog', 1442 'explanation', 1443 'related', 1444 'methods', 1445 'notes' 1446 ); 1447 1448 ob_start(); 1449 1450 foreach ( $templates as $part ) { 1451 get_template_part( 'reference/template', $part ); 1452 } 1453 1454 return ob_get_clean(); 1455 } 1442 1456 } 1443 1457 -
reference/template-changelog.php
1 <?php 2 /** 3 * Reference Template: Changelog 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 $changelog_data = get_changelog_data(); 12 if ( ! empty( $changelog_data ) ) : 13 ?> 14 <hr/> 15 <section class="changelog"> 16 <h3><?php _e( 'Changelog', 'wporg' ); ?></h3> 17 <ul> 18 <?php foreach ( $changelog_data as $version => $data ) : ?> 19 <li> 20 <strong><?php _e( 'Since:', 'wporg' ); ?></strong> 21 <?php printf( 22 /* translators: %s: WordPress version */ 23 __( 'WordPress %s', 'wporg' ), 24 sprintf( '<a href="%1$s">%2$s</a>', esc_url( $data['since_url'] ), esc_html( $version ) ) 25 ); ?> 26 <?php echo $data['description']; // escaped in get_changelog_data() ?> 27 </li> 28 <?php endforeach; ?> 29 </ul> 30 </section> 31 <?php endif; ?> 32 -
reference/template-description.php
1 <?php 2 /** 3 * Reference Template: Description 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 ?> 11 12 <hr /> 13 <section class="description"> 14 <h2><?php _e( 'Description', 'wporg' ); ?></h2> 15 <?php echo get_description(); ?> 16 </section> 17 -
reference/template-explanation.php
1 <?php 2 /** 3 * Reference Template: "More Information" 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 if ( $explanation = get_explanation_field( 'post_content', get_the_ID() ) ) : 12 ?> 13 <hr/> 14 <section class="explanation"> 15 <h2><?php _e( 'More Information', 'wporg' ); ?></h2> 16 17 <?php 18 // Output the explanation. Passed through 'the_content' on retrieval, thus no escaping. 19 echo apply_filters( 'the_content', apply_filters( 'get_the_content', $explanation ) ); 20 ?> 21 </section> 22 <?php endif; ?> -
reference/template-methods.php
1 <?php 2 /** 3 * Reference Template: Class Methods 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 if ( 'wp-parser-class' === get_post_type() ) : 12 if ( $children = get_children( array( 'post_parent' => get_the_ID(), 'post_status' => 'publish' ) ) ) : 13 usort( $children, __NAMESPACE__ . '\\compare_objects_by_name' ); 14 ?> 15 <hr/> 16 <section class="class-methods"> 17 <h2><?php _e( 'Methods', 'wporg' ); ?></h2> 18 <ul> 19 <?php foreach ( $children as $child ) : ?> 20 <li><a href="<?php echo get_permalink( $child->ID ); ?>"> 21 <?php 22 $title = get_the_title( $child ); 23 $pos = ( $i = strrpos( $title, ':' ) ) ? $i + 1 : 0; 24 echo substr( $title, $pos ); 25 ?></a> 26 <?php if ( $excerpt = apply_filters( 'get_the_excerpt', $child->post_excerpt ) ) { 27 echo '— ' . sanitize_text_field( $excerpt ); 28 } ?> 29 <?php if ( is_deprecated( $child->ID ) ) { 30 echo '— <span class="deprecated-method">' . __( 'deprecated', 'wporg' ) . '</span>'; 31 } ?> 32 </li> 33 <?php endforeach; ?> 34 </ul> 35 </section> 36 <?php endif; 37 endif; ?> -
reference/template-notes.php
1 <?php 2 /** 3 * Reference Template: User Contributed Notes 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 if ( comments_open() || '0' != get_comments_number() ) : 12 ?> 13 <hr /> 14 <section class="user-notes"> 15 <h2><?php _e( 'User Contributed Notes', 'wporg' ); ?></h2> 16 <?php comments_template(); /* TODO: add '/user-notes.php' */ ?> 17 </section> 18 <?php endif; ?> -
reference/template-params.php
1 <?php 2 /** 3 * Reference Template: Parameters 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 if ( $params = get_params() ) : 12 ?> 13 <hr/> 14 <section class="parameters"> 15 <h3><?php _e( 'Parameters', 'wporg' ); ?></h3> 16 <dl> 17 <?php foreach ( $params as $param ) : ?> 18 <?php if ( ! empty( $param['variable'] ) ) : ?> 19 <dt><?php echo esc_html( $param['variable'] ); ?></dt> 20 <?php endif; ?> 21 <dd> 22 <p class="desc"> 23 <?php if ( ! empty( $param['types'] ) ) : ?> 24 <span class="type"><?php printf( __( '(%s)', 'wporg' ), wp_kses_post( $param['types'] ) ); ?></span> 25 <?php endif; ?> 26 <?php if ( ! empty( $param['required'] ) && 'wp-parser-hook' !== get_post_type() ) : ?> 27 <span class="required"><?php printf( __( '(%s)', 'wporg' ), esc_html( $param['required'] ) ); ?></span> 28 <?php endif; ?> 29 <?php if ( ! empty( $param['content'] ) ) : ?> 30 <span class="description"><?php echo wp_kses_post( $param['content'] ); ?></span> 31 <?php endif; ?> 32 </p> 33 <?php if ( ! empty( $param['default'] ) ) : ?> 34 <p class="default"><?php _e( 'Default value:', 'wporg' );?> <?php echo htmlentities( $param['default'] ); ?></p> 35 <?php endif; ?> 36 </dd> 37 <?php endforeach; ?> 38 </dl> 39 </section> 40 <?php endif; ?> -
reference/template-related.php
1 <?php 2 /** 3 * Reference Template: Related Functionality 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 if ( show_usage_info() ) : 12 ?> 13 <hr id="related" /> 14 <section class="related"> 15 <h2><?php _e( 'Related', 'wporg' ); ?></h2> 16 17 <?php if ( post_type_has_uses_info() ) : ?> 18 <article class="uses"> 19 <h3><?php _e( 'Uses', 'wporg' ); ?></h3> 20 <ul> 21 <?php 22 $uses = get_uses(); 23 $uses_to_show = 5; 24 while ( $uses->have_posts() ) : $uses->the_post() 25 ?> 26 <li> 27 <span><?php echo esc_attr( get_source_file() ); ?>:</span> 28 <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( 'wp-parser-hook' !== get_post_type() ) : ?>()<?php endif; ?></a> 29 </li> 30 <?php endwhile; wp_reset_postdata(); ?> 31 <?php if ( $uses->post_count > $uses_to_show ) : ?> 32 <a href="#" class="show-more"><?php 33 /* translators: %d: remaining 'uses' count */ 34 printf( _n( 'Show %d more use', 'Show %d more uses', $uses->post_count - $uses_to_show, 'wporg' ), 35 number_format_i18n( $uses->post_count - $uses_to_show ) 36 ); 37 ?></a> 38 <a href="#" class="hide-more"><?php _e( 'Hide more uses', 'wporg' ); ?></a> 39 <?php endif; ?> 40 </ul> 41 </article> 42 <?php endif; ?> 43 44 <hr /> 45 <article class="used-by"> 46 <h3><?php _e( 'Used By', 'wporg' ); ?></h3> 47 <ul> 48 <?php 49 $used_by = get_used_by(); 50 $used_by_to_show = 5; 51 while ( $used_by->have_posts() ) : $used_by->the_post(); 52 ?> 53 <li> 54 <span><?php echo esc_attr( get_source_file() ); ?>:</span> 55 <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php if ( 'wp-parser-hook' !== get_post_type() ) : ?>()<?php endif; ?></a> 56 </li> 57 <?php endwhile; wp_reset_postdata(); ?> 58 <?php if ( $used_by->post_count > $used_by_to_show ) : ?> 59 <a href="#" class="show-more"><?php 60 /* translators: %d: remaining 'used by' count */ 61 printf( _n( 'Show %d more used by', 'Show %d more used by', $used_by->post_count - $used_by_to_show, 'wporg' ), 62 number_format_i18n( $used_by->post_count - $used_by_to_show ) 63 ); 64 ?></a> 65 <a href="#" class="hide-more"><?php _e( 'Hide more used by', 'wporg' ); ?></a> 66 <?php endif; ?> 67 </ul> 68 </article> 69 </section> 70 <?php endif; ?> 71 -
reference/template-return.php
1 <?php 2 /** 3 * Reference Template: Return Information 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 $return = get_return(); 12 if ( ! empty( $return ) ) : 13 ?> 14 <hr /> 15 <section class="return"> 16 <h3><?php _e( 'Return', 'wporg' ); ?></h3> 17 <p><?php echo $return; ?></p> 18 </section> 19 <?php endif; ?> -
reference/template-source.php
1 <?php 2 /** 3 * Reference Template: Source Information 4 * 5 * @package wporg-developer 6 * @subpackage Reference 7 */ 8 9 namespace DevHub; 10 11 $source_file = get_source_file(); 12 if ( ! empty( $source_file ) ) : 13 ?> 14 <hr /> 15 <section class="source"> 16 <h3><?php _e( 'Source', 'wporg' ); ?></h3> 17 <p> 18 <?php printf( __( 'File: %s', 'wporg' ), 19 '<a href="' . esc_url( get_source_file_archive_link( $source_file ) ) . '">' . esc_html( $source_file ) . '</a>' 20 ); ?> 21 </p> 22 23 <?php if ( post_type_has_source_code() ) : ?> 24 <div class="source-code-container"> 25 <pre class="brush: php; toolbar: false; first-line: <?php echo esc_attr( get_post_meta( get_the_ID(), '_wp-parser_line_num', true ) ); ?>"><?php echo htmlentities( get_source_code() ); ?></pre> 26 </div> 27 <p class="source-code-links"> 28 <span> 29 <a href="#" class="show-complete-source"><?php _e( 'Expand full source code', 'wporg' ); ?></a> 30 <a href="#" class="less-complete-source"><?php _e( 'Collapse full source code', 'wporg' ); ?></a> 31 </span> 32 </p> 33 <?php endif; ?> 34 <p> 35 <a href="<?php echo get_source_file_link(); ?>"><?php _e( 'View on Trac', 'wporg' ); ?></a> 36 </p> 37 </section> 38 <?php endif; ?> -
scss/main.scss
1428 1428 1429 1429 li { 1430 1430 padding-bottom: 6px !important; 1431 font-weight: 600; 1431 1432 1432 1433 ul li, 1433 1434 ul li ul li { 1434 1435 padding-bottom: 0 !important; 1436 font-weight: normal; 1435 1437 } 1436 1438 1437 1439 a { -
stylesheets/main.css
1527 1527 } 1528 1528 .devhub-wrap ul.items li { 1529 1529 padding-bottom: 6px !important; 1530 font-weight: 600; 1530 1531 } 1531 1532 .devhub-wrap ul.items li ul li, 1532 1533 .devhub-wrap ul.items li ul li ul li { 1533 1534 padding-bottom: 0 !important; 1535 font-weight: normal; 1534 1536 } 1535 1537 .devhub-wrap ul.items li a { 1536 1538 color: #555 !important;