WordPress.org

Making WordPress.org

Changeset 5598


Ignore:
Timestamp:
06/27/2017 10:34:19 PM (11 months ago)
Author:
coffee2code
Message:

developer.wordpress.org: Handle hook deprecation.

Props DrewAPicture.
Fixes #1766.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php

    r5476 r5598  
    114114                    case 'filter_reference':
    115115                        $type = __( 'Filter Hook', 'wporg' );
     116                        break;
     117                    case 'action_deprecated':
     118                        $type = __( 'Action Hook (deprecated)', 'wporg' );
     119                        break;
     120                    case 'filter_deprecated':
     121                        $type = __( 'Filter Hook (deprecated)', 'wporg' );
    116122                        break;
    117123                }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/formatting.php

    r5595 r5598  
    160160     *
    161161     * @param string $link Element string.
    162      * @param string HTML link markup if a valid element was found.
    163      */
    164     public static function link_internal_element( $link ) {
     162     * @param bool   $tag  Optional. Whether the element was explicitly provided in a tag
     163     *                     description, such as `@see 'hook_name'` vs in random context.
     164     *                     Default false.
     165     * @return string HTML link markup if a valid element was found.
     166     */
     167    public static function link_internal_element( $link, $tag = false ) {
    165168        // Link to class variable: {@see WP_Rewrite::$index}
    166169        if ( false !== strpos( $link, '::$' ) ) {
     
    176179        }
    177180
    178         // Link to hook: {@see 'pre_get_search_form'}
    179         elseif ( 1 === preg_match( '/^(?:\'|(?:‘))([\$\w-&;]+)(?:\'|(?:’))$/', $link, $hook ) ) {
     181        // Link to hook: {@see 'pre_get_search_form'} (or 'pre_get_search_form' if $tag is true)
     182        elseif (
     183            1 === preg_match( '/^(?:\'|(?:‘))([\$\w-&;]+)(?:\'|(?:’))$/', $link, $hook )
     184            || ( true === $tag && 1 === preg_match( '/^(?:\')([\$\w-&;]+)(?:\')$/', $link, $hook ) )
     185        ) {
    180186            if ( ! empty( $hook[1] ) ) {
    181187                $link = '<a href="' .
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r5597 r5598  
    556556            $hook_type = get_post_meta( $post_id, '_wp-parser_hook_type', true );
    557557            if ( false !== strpos( $hook_type, 'action' ) ) {
    558                 $hook_type = ( 'action_reference' === $hook_type ) ? 'do_action_ref_array' : 'do_action';
     558                if ( 'action_reference' === $hook_type ) {
     559                    $hook_type = 'do_action_ref_array';
     560                } elseif ( 'action_deprecated' === $hook_type ) {
     561                    $hook_type = 'do_action_deprecated';
     562                } else {
     563                    $hook_type = 'do_action';
     564                }
    559565            } else {
    560                 $hook_type = ( 'filter_reference' === $hook_type ) ? 'apply_filters_ref_array' : 'apply_filters';
     566                if ( 'filter_reference' === $hook_type ) {
     567                    $hook_type = 'apply_filters_ref_array';
     568                } elseif ( 'filter_deprecated' === $hook_type ) {
     569                    $hook_type = 'apply_filters_deprecated';
     570                } else {
     571                    $hook_type = 'apply_filters';
     572                }
    561573            }
    562574
Note: See TracChangeset for help on using the changeset viewer.