Ticket #1498: 1498.diff
File 1498.diff, 6.5 KB (added by , 8 years ago) |
---|
-
content-reference.php
4 4 5 5 <?php echo get_deprecated(); ?> 6 6 7 <?php echo get_private_access_message(); ?> 8 7 9 <h1><a href="<?php the_permalink() ?>"><?php echo get_signature(); ?></a></h1> 8 10 9 11 <section class="summary"> -
inc/formatting.php
132 132 133 133 // Link to an internal resource. 134 134 else { 135 136 // Link to class variable: {@see WP_Rewrite::$index} 137 if ( false !== strpos( $link, '::$' ) ) { 138 // Nothing to link to currently. 139 } 140 141 // Link to class method: {@see WP_Query::query()} 142 elseif ( false !== strpos( $link, '::' ) ) { 143 $link = '<a href="' . 144 get_post_type_archive_link( 'wp-parser-class' ) . 145 str_replace( array( '::', '()' ), array( '/', '' ), $link ) . 146 '">' . esc_html( $link ) . '</a>'; 147 } 148 149 // Link to hook: {@see 'pre_get_search_form'} 150 elseif ( 1 === preg_match( '/^(‘)\w+(’)$/', $link, $hook ) ) { 151 if ( ! empty( $hook[0] ) ) { 152 $link = '<a href="' . 153 get_post_type_archive_link( 'wp-parser-hook' ) . 154 str_replace( array( '‘', '’' ), '', $link ) . 155 '">' . esc_html( $link ) . '</a>'; 156 } 157 } 158 159 // Link to function: {@see esc_attr()} 160 else { 161 $link = '<a href="' . 162 get_post_type_archive_link( 'wp-parser-function' ) . 163 str_replace( '()', '', $link ) . 164 '">' . esc_html( $link ) . '</a>'; 165 } 166 135 $link = self::get_internal_element_link( $link ); 167 136 } 168 137 169 138 return $link; … … 173 142 } 174 143 175 144 /** 145 * Parses and links an internal element if a valid element is found. 146 * 147 * @static 148 * @access public 149 * 150 * @param string $link Element string. 151 * @param string HTML link markup if a valid element was found. 152 */ 153 public static function get_internal_element_link( $link ) { 154 // Link to class variable: {@see WP_Rewrite::$index} 155 if ( false !== strpos( $link, '::$' ) ) { 156 // Nothing to link to currently. 157 } 158 159 // Link to class method: {@see WP_Query::query()} 160 elseif ( false !== strpos( $link, '::' ) ) { 161 $link = '<a href="' . 162 get_post_type_archive_link( 'wp-parser-class' ) . 163 str_replace( array( '::', '()' ), array( '/', '' ), $link ) . 164 '">' . esc_html( $link ) . '</a>'; 165 } 166 167 // Link to hook: {@see 'pre_get_search_form'} 168 elseif ( 1 === preg_match( '/^(‘)\w+(’)$/', $link, $hook ) ) { 169 if ( ! empty( $hook[0] ) ) { 170 $link = '<a href="' . 171 get_post_type_archive_link( 'wp-parser-hook' ) . 172 str_replace( array( '‘', '’' ), '', $link ) . 173 '">' . esc_html( $link ) . '</a>'; 174 } 175 } 176 177 // Link to function: {@see esc_attr()} 178 else { 179 $link = '<a href="' . 180 get_post_type_archive_link( 'wp-parser-function' ) . 181 str_replace( '()', '', $link ) . 182 '">' . esc_html( $link ) . '</a>'; 183 } 184 return $link; 185 } 186 187 /** 176 188 * Fixes unintended markup generated by Markdown during parsing. 177 189 * 178 190 * The parser interprets underscores surrounding text as Markdown indicating -
inc/template-tags.php
1349 1349 } 1350 1350 return get_post_field( $field, $explanation, $context ); 1351 1351 } 1352 1353 /** 1354 * Retrieves private access data for a given post. 1355 * 1356 * @param int|WP_Post $post Optional. Post object or ID. Default global `$post`. 1357 * @return string Private access message if the given reference is considered "private". 1358 */ 1359 function get_private_access_message( $post = null ) { 1360 if ( ! $post = get_post( $post ) ) { 1361 return ''; 1362 } 1363 1364 // Currently only handling private access messages for functions and hooks. 1365 if ( ! in_array( get_post_type( $post ), array( 'wp-parser-function', 'wp-parser-hook' ) ) ) { 1366 return ''; 1367 } 1368 1369 $tags = get_post_meta( $post->ID, '_wp-parser_tags', true ); 1370 $access_tags = wp_filter_object_list( $tags, array( 1371 'name' => 'access', 1372 'content' => 'private' 1373 ) ); 1374 1375 if ( ! empty( $access_tags ) ) { 1376 $referral = array_shift( wp_filter_object_list( $tags, array( 'name' => 'see' ) ) ); 1377 1378 if ( ! empty( $referral['refers'] ) ) { 1379 $refers = sanitize_text_field( $referral['refers'] ); 1380 1381 if ( ! empty( $refers ) ) { 1382 /* translators: 1: Linked internal element name */ 1383 $altnerative_string = sprintf( __( ' Use %s instead.', 'wporg' ), \DevHub_Formatting::get_internal_element_link( $refers ) ); 1384 } 1385 } else { 1386 $altnerative_string = ''; 1387 } 1388 1389 return 1390 '<p class="private-access">' . 1391 /* translators: 1: String for alternative function (if one exists) */ 1392 sprintf( __( 'This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.%s', 'wporg' ), 1393 $altnerative_string 1394 ) . 1395 '</p>'; 1396 } 1397 } 1352 1398 } -
scss/main.scss
1019 1019 color: #be2423; 1020 1020 font-style: italic; 1021 1021 } 1022 .private-access { 1023 color: #be2423; 1024 font-weight: bold; 1025 padding: 20px; 1026 } 1022 1027 } 1023 1028 1024 1029 &.archive, &.search { -
stylesheets/main.css
1222 1222 color: #be2423; 1223 1223 font-style: italic; 1224 1224 } 1225 .devhub-wrap .wp-parser-class .private-access, .devhub-wrap .wp-parser-function .private-access, .devhub-wrap .wp-parser-hook .private-access, .devhub-wrap .wp-parser-method .private-access { 1226 color: #be2423; 1227 font-weight: bold; 1228 padding: 20px; 1229 } 1225 1230 .devhub-wrap.archive .wp-parser-class h1 a, .devhub-wrap.archive .wp-parser-function h1 a, .devhub-wrap.archive .wp-parser-hook h1 a, .devhub-wrap.archive .wp-parser-method h1 a, .devhub-wrap.search .wp-parser-class h1 a, .devhub-wrap.search .wp-parser-function h1 a, .devhub-wrap.search .wp-parser-hook h1 a, .devhub-wrap.search .wp-parser-method h1 a { 1226 1231 font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; 1227 1232 color: #21759b;