wp_list_filter example



            $body[] = '';
        }

        // Plugins, Themes, Translations.         foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) {
            if ( ! isset( $this->update_results[ $type ] ) ) {
                continue;
            }

            $success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );

            if ( $success_items ) {
                $messages = array(
                    'plugin'      => __( 'The following plugins were successfully updated:' ),
                    'theme'       => __( 'The following themes were successfully updated:' ),
                    'translation' => __( 'The following translations were successfully updated:' ),
                );

                $body[] = $messages[ $type ];
                foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) {
                    /* translators: %s: Name of plugin / theme / translation. */
                    
$data['xfn'] = array_map( 'sanitize_html_class', explode( ' ', $menu_item->xfn ) );
        }

        if ( rest_is_field_included( 'invalid', $fields ) ) {
            $data['invalid'] = (bool) $menu_item->_invalid;
        }

        if ( rest_is_field_included( 'meta', $fields ) ) {
            $data['meta'] = $this->meta->get_value( $menu_item->ID, $request );
        }

        $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );

        foreach ( $taxonomies as $taxonomy ) {
            $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;

            if ( rest_is_field_included( $base$fields ) ) {
                $terms = get_the_terms( $item$taxonomy->name );
                if ( ! is_array( $terms ) ) {
                    continue;
                }
                $term_ids = $terms ? array_values( wp_list_pluck( $terms, 'term_id' ) ) : array();
                if ( 'nav_menu' === $taxonomy->name ) {
                    

    public function prepare_item_for_response( $item$request ) {
        // Restores the more descriptive, specific name for use within this method.         $post_type  = $item;
        $taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) );
        $taxonomies = wp_list_pluck( $taxonomies, 'name' );
        $base       = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name;
        $namespace  = ! empty( $post_type->rest_namespace ) ? $post_type->rest_namespace : 'wp/v2';
        $supports   = get_all_post_type_supports( $post_type->name );

        $fields = $this->get_fields_for_response( $request );
        $data   = array();

        if ( rest_is_field_included( 'capabilities', $fields ) ) {
            $data['capabilities'] = $post_type->cap;
        }

        

function _access_denied_splash() {
    if ( ! is_user_logged_in() || is_network_admin() ) {
        return;
    }

    $blogs = get_blogs_of_user( get_current_user_id() );

    if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) {
        return;
    }

    $blog_name = get_bloginfo( 'name' );

    if ( empty( $blogs ) ) {
        wp_die(
            sprintf(
                /* translators: 1: Site title. */
                __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ),
                $blog_name
            ),
/** * Updates the post's terms from a REST request. * * @since 4.7.0 * * @param int $post_id The post ID to update the terms form. * @param WP_REST_Request $request The request object with post and terms data. * @return null|WP_Error WP_Error on an error assigning any of the terms, otherwise null. */
    protected function handle_terms( $post_id$request ) {
        $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );

        foreach ( $taxonomies as $taxonomy ) {
            $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;

            if ( ! isset( $request[ $base ] ) ) {
                continue;
            }

            $result = wp_set_object_terms( $post_id$request[ $base ]$taxonomy->name );

            if ( is_wp_error( $result ) ) {
                

    public function remove_link( $rel$href = null ) {
        if ( ! isset( $this->links[ $rel ] ) ) {
            return;
        }

        if ( $href ) {
            $this->links[ $rel ] = wp_list_filter( $this->links[ $rel ], array( 'href' => $href ), 'NOT' );
        } else {
            $this->links[ $rel ] = array();
        }

        if ( ! $this->links[ $rel ] ) {
            unset( $this->links[ $rel ] );
        }
    }

    /** * Adds multiple links to the response. * * Link data should be an associative array with link relation as the key. * The value can either be an associative array of link attributes * (including `href` with the URL for the response), or a list of these * associative arrays. * * @since 4.4.0 * * @param array $links Map of link relation to list of links. */

    public function get_routes( $route_namespace = '' ) {
        $endpoints = $this->endpoints;

        if ( $route_namespace ) {
            $endpoints = wp_list_filter( $endpoints, array( 'namespace' => $route_namespace ) );
        }

        /** * Filters the array of available REST API endpoints. * * @since 4.4.0 * * @param array $endpoints The available endpoints. An array of matching regex patterns, each mapped * to an array of callbacks for the endpoint. These take the format * `'/path/regex' => array( $callback, $bitmask )` or * `'/path/regex' => array( array( $callback, $bitmask ). */
Home | Imprint | This part of the site doesn't use cookies.