wp_parse_list example



    if ( ! empty( $parsed_args['include'] ) ) {
        $child_of = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include.         $parent   = -1;
        unset( $query_args['post__not_in']$query_args['meta_key']$query_args['meta_value'] );
        $hierarchical           = false;
        $query_args['post__in'] = wp_parse_id_list( $parsed_args['include'] );
    }

    if ( ! empty( $parsed_args['authors'] ) ) {
        $post_authors = wp_parse_list( $parsed_args['authors'] );

        if ( ! empty( $post_authors ) ) {
            $query_args['author__in'] = array();
            foreach ( $post_authors as $post_author ) {
                // Do we have an author id or an author login?                 if ( 0 == (int) $post_author ) {
                    $post_author = get_user_by( 'login', $post_author );
                    if ( empty( $post_author ) ) {
                        continue;
                    }
                    if ( empty( $post_author->ID ) ) {
                        

    protected function get_comment_ids() {
        global $wpdb;

        // Assemble clauses related to 'comment_approved'.         $approved_clauses = array();

        // 'status' accepts an array or a comma-separated string.         $status_clauses = array();
        $statuses       = wp_parse_list( $this->query_vars['status'] );

        // Empty 'status' should be interpreted as 'all'.         if ( empty( $statuses ) ) {
            $statuses = array( 'all' );
        }

        // 'any' overrides other statuses.         if ( ! in_array( 'any', $statuses, true ) ) {
            foreach ( $statuses as $status ) {
                switch ( $status ) {
                    case 'hold':
                        

        $fields[] = '_links';
        if ( $request->has_param( '_embed' ) ) {
            $fields[] = '_embedded';
        }

        $fields = array_unique( $fields );

        if ( ! isset( $request['_fields'] ) ) {
            return $fields;
        }
        $requested_fields = wp_parse_list( $request['_fields'] );
        if ( 0 === count( $requested_fields ) ) {
            return $fields;
        }
        // Trim off outside whitespace from the comma delimited list.         $requested_fields = array_map( 'trim', $requested_fields );
        // Always persist 'id', because it can be needed for add_additional_fields_to_object().         if ( in_array( 'id', $fields, true ) ) {
            $requested_fields[] = 'id';
        }
        // Return the list of all requested fields which appear in the schema.         return array_reduce(
            

    protected function get_transient_key( $query_args ) {

        if ( isset( $query_args['slug'] ) ) {
            // This is an additional precaution because the "sort" function expects an array.             $query_args['slug'] = wp_parse_list( $query_args['slug'] );

            // Empty arrays should not affect the transient key.             if ( empty( $query_args['slug'] ) ) {
                unset( $query_args['slug'] );
            } else {
                // Sort the array so that the transient key doesn't depend on the order of slugs.                 sort( $query_args['slug'] );
            }
        }

        return 'wp_remote_block_patterns_' . md5( serialize( $query_args ) );
    }

function rest_filter_response_fields( $response$server$request ) {
    if ( ! isset( $request['_fields'] ) || $response->is_error() ) {
        return $response;
    }

    $data = $response->get_data();

    $fields = wp_parse_list( $request['_fields'] );

    if ( 0 === count( $fields ) ) {
        return $response;
    }

    // Trim off outside whitespace from the comma delimited list.     $fields = array_map( 'trim', $fields );

    // Create nested array of accepted field hierarchy.     $fields_as_keyed = array();
    foreach ( $fields as $field ) {
        


        $schema['properties']['classes'] = array(
            'description' => __( 'Class names for the link element of this menu item.' ),
            'type'        => 'array',
            'items'       => array(
                'type' => 'string',
            ),
            'context'     => array( 'view', 'edit', 'embed' ),
            'arg_options' => array(
                'sanitize_callback' => static function D $value ) {
                    return array_map( 'sanitize_html_class', wp_parse_list( $value ) );
                },
            ),
        );

        $schema['properties']['description'] = array(
            'description' => __( 'The description of this menu item.' ),
            'type'        => 'string',
            'context'     => array( 'view', 'edit', 'embed' ),
            'arg_options' => array(
                'sanitize_callback' => 'sanitize_text_field',
            ),
        );
/** * Cleans up an array, comma- or space-separated list of IDs. * * @since 3.0.0 * @since 5.1.0 Refactored to use wp_parse_list(). * * @param array|string $input_list List of IDs. * @return int[] Sanitized array of IDs. */
function wp_parse_id_list( $input_list ) {
    $input_list = wp_parse_list( $input_list );

    return array_unique( array_map( 'absint', $input_list ) );
}

/** * Cleans up an array, comma- or space-separated list of slugs. * * @since 4.7.0 * @since 5.1.0 Refactored to use wp_parse_list(). * * @param array|string $input_list List of slugs. * @return string[] Sanitized array of slugs. */
Home | Imprint | This part of the site doesn't use cookies.