_wp_preview_terms_filter

The timeline below displays how wordpress function _wp_preview_terms_filter has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Filters terms lookup to set the post format.
 *
 * @since 3.6.0
 * @access private
 *
 * @param array  $terms
 * @param int    $post_id
 * @param string $taxonomy
 * @return array
 */
function _wp_preview_terms_filter($terms, $post_id, $taxonomy)
{
    $post = get_post();
    if (!$post) {
        return $terms;
    }
    if (empty($_REQUEST['post_format']) || $post->ID !== $post_id || 'post_format' !== $taxonomy || 'revision' === $post->post_type) {
        return $terms;
    }
    if ('standard' === $_REQUEST['post_format']) {
        $terms = array();
    } else {
        $term = get_term_by('slug', 'post-format-' . sanitize_key($_REQUEST['post_format']), 'post_format');
        if ($term) {
            $terms = array($term);
            // Can only have one post format.
        }
    }
    return $terms;
}

WordPress Version: 5.5

/**
 * Filters terms lookup to set the post format.
 *
 * @since 3.6.0
 * @access private
 *
 * @param array  $terms
 * @param int    $post_id
 * @param string $taxonomy
 * @return array
 */
function _wp_preview_terms_filter($terms, $post_id, $taxonomy)
{
    $post = get_post();
    if (!$post) {
        return $terms;
    }
    if (empty($_REQUEST['post_format']) || $post->ID != $post_id || 'post_format' !== $taxonomy || 'revision' === $post->post_type) {
        return $terms;
    }
    if ('standard' === $_REQUEST['post_format']) {
        $terms = array();
    } else {
        $term = get_term_by('slug', 'post-format-' . sanitize_key($_REQUEST['post_format']), 'post_format');
        if ($term) {
            $terms = array($term);
            // Can only have one post format.
        }
    }
    return $terms;
}

WordPress Version: 5.4

/**
 * Filters terms lookup to set the post format.
 *
 * @since 3.6.0
 * @access private
 *
 * @param array  $terms
 * @param int    $post_id
 * @param string $taxonomy
 * @return array
 */
function _wp_preview_terms_filter($terms, $post_id, $taxonomy)
{
    $post = get_post();
    if (!$post) {
        return $terms;
    }
    if (empty($_REQUEST['post_format']) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type) {
        return $terms;
    }
    if ('standard' == $_REQUEST['post_format']) {
        $terms = array();
    } else {
        $term = get_term_by('slug', 'post-format-' . sanitize_key($_REQUEST['post_format']), 'post_format');
        if ($term) {
            $terms = array($term);
            // Can only have one post format.
        }
    }
    return $terms;
}

WordPress Version: 5.3

/**
 * Filters terms lookup to set the post format.
 *
 * @since 3.6.0
 * @access private
 *
 * @param array  $terms
 * @param int    $post_id
 * @param string $taxonomy
 * @return array
 */
function _wp_preview_terms_filter($terms, $post_id, $taxonomy)
{
    $post = get_post();
    if (!$post) {
        return $terms;
    }
    if (empty($_REQUEST['post_format']) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type) {
        return $terms;
    }
    if ('standard' == $_REQUEST['post_format']) {
        $terms = array();
    } else {
        $term = get_term_by('slug', 'post-format-' . sanitize_key($_REQUEST['post_format']), 'post_format');
        if ($term) {
            $terms = array($term);
            // Can only have one post format
        }
    }
    return $terms;
}

WordPress Version: 5.1

/**
 * Filters terms lookup to set the post format.
 *
 * @since 3.6.0
 * @access private
 *
 * @param array  $terms
 * @param int    $post_id
 * @param string $taxonomy
 * @return array
 */
function _wp_preview_terms_filter($terms, $post_id, $taxonomy)
{
    if (!$post = get_post()) {
        return $terms;
    }
    if (empty($_REQUEST['post_format']) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type) {
        return $terms;
    }
    if ('standard' == $_REQUEST['post_format']) {
        $terms = array();
    } elseif ($term = get_term_by('slug', 'post-format-' . sanitize_key($_REQUEST['post_format']), 'post_format')) {
        $terms = array($term);
        // Can only have one post format
    }
    return $terms;
}

WordPress Version: 4.3

/**
 * Filters terms lookup to set the post format.
 *
 * @since 3.6.0
 * @access private
 *
 * @param array  $terms
 * @param int    $post_id
 * @param string $taxonomy
 * @return array
 */
function _wp_preview_terms_filter($terms, $post_id, $taxonomy)
{
    if (!$post = get_post()) {
        return $terms;
    }
    if (empty($_REQUEST['post_format']) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type) {
        return $terms;
    }
    if ('standard' == $_REQUEST['post_format']) {
        $terms = array();
    } elseif ($term = get_term_by('slug', 'post-format-' . sanitize_key($_REQUEST['post_format']), 'post_format')) {
        $terms = array($term);
    }
    // Can only have one post format
    return $terms;
}

WordPress Version: 3.7

/**
 * Filters terms lookup to set the post format.
 *
 * @since 3.6.0
 * @access private
 */
function _wp_preview_terms_filter($terms, $post_id, $taxonomy)
{
    if (!$post = get_post()) {
        return $terms;
    }
    if (empty($_REQUEST['post_format']) || $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type) {
        return $terms;
    }
    if ('standard' == $_REQUEST['post_format']) {
        $terms = array();
    } elseif ($term = get_term_by('slug', 'post-format-' . sanitize_key($_REQUEST['post_format']), 'post_format')) {
        $terms = array($term);
    }
    // Can only have one post format
    return $terms;
}