Changeset 2290
- Timestamp:
- 01/12/2016 10:59:50 PM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php
r2041 r2290 93 93 * Prefixes excerpts for archive view with content type label. 94 94 * 95 * @param string$excerpt The excerpt.95 * @param string $excerpt The excerpt. 96 96 * @return string 97 97 */ 98 98 function wporg_filter_archive_excerpt( $excerpt ) { 99 99 if ( ! is_single() ) { 100 $excerpt = '<b>' . get_post_type_object( get_post_type( get_the_ID() ) )->labels->singular_name . ': </b>' . $excerpt; 100 101 $post_id = get_the_ID(); 102 $type = get_post_type_object( get_post_type( $post_id ) )->labels->singular_name; 103 104 if ( 'hook' === strtolower( $type ) ) { 105 $hook_type = \DevHub\get_hook_type( $post_id ); 106 107 if ( isset( $hook_type ) ) { 108 switch ( $hook_type ) { 109 case 'action': 110 $type = __( 'Action Hook', 'wporg' ); 111 break; 112 case 'filter': 113 $type = __( 'Filter Hook', 'wporg' ); 114 break; 115 } 116 } 117 } 118 $excerpt = '<b>' . $type . ': </b>' . $excerpt; 101 119 } 102 120 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r2282 r2290 440 440 441 441 return in_array( $post_type, get_parsed_post_types() ); 442 } 443 444 /** 445 * Get the specific type of hook. 446 * 447 * @param int|WP_Post|null $post Optional. Post ID or post object. Default is global $post. 448 * @return string Either 'action', 'filter', or an empty string if not a hook post type. 449 */ 450 function get_hook_type( $post = null ) { 451 $hook = ''; 452 453 if ( 'wp-parser-hook' === get_post_type( $post ) ) { 454 $hook = get_post_meta( get_post_field( 'ID', $post ), '_wp-parser_hook_type', true ); 455 } 456 457 return $hook; 442 458 } 443 459
Note: See TracChangeset
for help on using the changeset viewer.