WordPress.org

Make WordPress Core

Ticket #18561: 18561.get_template_part_slug.patch

File 18561.get_template_part_slug.patch, 1.4 KB (added by SergeyBiryukov, 7 years ago)
  • wp-includes/general-template.php

     
    111111 *
    112112 * @uses locate_template()
    113113 * @since 3.0.0
    114  * @uses do_action() Calls 'get_template_part{$slug}' action.
     114 * @uses do_action() Calls 'get_template_part_{$slug}' and "get_template_part_{$slug}_after" actions.
    115115 *
    116116 * @param string $slug The slug name for the generic template.
    117117 * @param string $name The name of the specialised template.
     
    126126        $templates[] = "{$slug}.php";
    127127
    128128        locate_template($templates, true, false);
     129
     130        do_action( "get_template_part_{$slug}_after", $slug, $name );
    129131}
    130132
    131133/**
     134 * Determine the actual template part slug used by current theme
     135 *
     136 * Makes it easy for a plugin to hook into "get_template_part_{$slug}" or
     137 * "get_template_part_{$slug}_after".
     138 *
     139 * @since 3.3.0
     140 * @uses get_theme_support()
     141 *
     142 * @param string $slug The slug name for the generic template.
     143 */
     144function get_template_part_slug( $slug ) {
     145        if ( ! current_theme_supports( 'template-parts' ) )
     146                return false;
     147
     148        $template_parts = get_theme_support( 'template-parts' );
     149
     150        if ( isset( $template_parts[0][$slug] ) )
     151                return $template_parts[0][$slug];
     152
     153        return false;
     154}
     155 
     156/**
    132157 * Display search form.
    133158 *
    134159 * Will first attempt to locate the searchform.php file in either the child or