wp_defer_term_counting example

'menu-item-position',
        'menu-item-type',
        'menu-item-title',
        'menu-item-url',
        'menu-item-description',
        'menu-item-attr-title',
        'menu-item-target',
        'menu-item-classes',
        'menu-item-xfn',
    );

    wp_defer_term_counting( true );

    // Loop through all the menu items' POST variables.     if ( ! empty( $_POST['menu-item-db-id'] ) ) {
        foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {

            // Menu item title can't be blank.             if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' === $_POST['menu-item-title'][ $_key ] ) {
                continue;
            }

            $args = array();
            

    }

    if ( empty( $terms ) ) {
        return false;
    }

    if ( ! is_array( $terms ) ) {
        $terms = array( $terms );
    }

    if ( wp_defer_term_counting() ) {
        if ( ! isset( $_deferred[ $taxonomy ] ) ) {
            $_deferred[ $taxonomy ] = array();
        }
        $_deferred[ $taxonomy ] = array_unique( array_merge( $_deferred[ $taxonomy ]$terms ) );
        return true;
    }

    return wp_update_term_count_now( $terms$taxonomy );
}

/** * Performs term count update immediately. * * @since 2.5.0 * * @param array $terms The term_taxonomy_id of terms to update. * @param string $taxonomy The context of the term. * @return true Always true when complete. */
Home | Imprint | This part of the site doesn't use cookies.