WordPress.org

Make WordPress Core

Ticket #40661: filter-term-query-results.patch

File filter-term-query-results.patch, 905 bytes (added by mpol, 3 years ago)

term_query_results filter for get_terms method, including docblock.

  • wp-includes/class-wp-term-query.php

    diff -uNr wordpress-term-query-results-filter/wp-includes/class-wp-term-query.php wordpress/wp-includes/class-wp-term-query.php
    old new  
    693693                }
    694694
    695695                $terms = $wpdb->get_results( $this->request );
     696
     697                /**
     698                 * Filters the array of retrieved terms after they've been fetched but
     699                 * before updating caches and returning them.
     700                 *
     701                 * @since 4.9.0
     702                 *
     703                 * @param array    $terms The array of retrieved terms.
     704                 * @param WP_Query &$this The WP_Term_Query instance (passed by reference).
     705                 */
     706                $terms = apply_filters_ref_array( 'term_query_results', array( $terms, &$this ) );
     707
    696708                if ( 'all' == $_fields || 'all_with_object_id' === $_fields ) {
    697709                        update_term_cache( $terms );
    698710                }