WordPress.org

Make WordPress Core

Ticket #21676: 21676.3.patch

File 21676.3.patch, 2.9 KB (added by sc0ttkclark, 15 months ago)

Refreshed, using $args instead of $data for future-proofing additional functionality

  • wp-includes/template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    363363 * @param string|array $template_names Template file(s) to search for, in order. 
    364364 * @param bool $load If true the template file will be loaded if it is found. 
    365365 * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false. 
     366 * @param array $args An array of arguments to control template handling. 
    366367 * @return string The template filename if one is located. 
    367368 */ 
    368 function locate_template($template_names, $load = false, $require_once = true ) { 
     369function locate_template($template_names, $load = false, $require_once = true, $args = array() ) { 
    369370        $located = ''; 
    370371        foreach ( (array) $template_names as $template_name ) { 
    371372                if ( !$template_name ) 
     
    380381        } 
    381382 
    382383        if ( $load && '' != $located ) 
    383                 load_template( $located, $require_once ); 
     384                load_template( $located, $require_once, $args ); 
    384385 
    385386        return $located; 
    386387} 
     
    396397 * 
    397398 * @param string $_template_file Path to template file. 
    398399 * @param bool $require_once Whether to require_once or require. Default true. 
     400 * @param array $args An array of arguments to control template handling. 
    399401 */ 
    400 function load_template( $_template_file, $require_once = true ) { 
     402function load_template( $_template_file, $require_once = true, $args = array() ) { 
    401403        global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; 
     404 
     405        if ( is_array( $args ) && isset( $args[ 'data' ] ) ) 
     406                extract( $args[ 'data' ], EXTR_SKIP ); 
    402407 
    403408        if ( is_array( $wp_query->query_vars ) ) 
    404409                extract( $wp_query->query_vars, EXTR_SKIP ); 
  • wp-includes/general-template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    115115 * 
    116116 * @param string $slug The slug name for the generic template. 
    117117 * @param string $name The name of the specialised template. 
     118 * @param array $args An array of arguments to control template handling. 
    118119 */ 
    119 function get_template_part( $slug, $name = null ) { 
    120         do_action( "get_template_part_{$slug}", $slug, $name ); 
     120function get_template_part( $slug, $name = null, $args = array() ) { 
     121        do_action( "get_template_part_{$slug}", $slug, $name, $args ); 
    121122 
    122123        $templates = array(); 
    123124        if ( isset($name) ) 
     
    125126 
    126127        $templates[] = "{$slug}.php"; 
    127128 
    128         locate_template($templates, true, false); 
     129        locate_template($templates, true, false, $args); 
    129130} 
    130131 
    131132/**