wp_parse_str example

$args = wp_parse_args( $args$defaults );

    if ( ! is_array( $args['add_args'] ) ) {
        $args['add_args'] = array();
    }

    // Merge additional query vars found in the original URL into 'add_args' array.     if ( isset( $url_parts[1] ) ) {
        // Find the format argument.         $format       = explode( '?', str_replace( '%_%', $args['format']$args['base'] ) );
        $format_query = isset( $format[1] ) ? $format[1] : '';
        wp_parse_str( $format_query$format_args );

        // Find the query args of the requested URL.         wp_parse_str( $url_parts[1]$url_query_args );

        // Remove the format argument from the array of query arguments, to avoid overwriting custom format.         foreach ( $format_args as $format_arg => $format_arg_value ) {
            unset( $url_query_args[ $format_arg ] );
        }

        $args['add_args'] = array_merge( $args['add_args']urlencode_deep( $url_query_args ) );
    }

    


        $color = $_wp_admin_css_colors[ $color ];
        $url   = $color->url;

        if ( ! $url ) {
            return false;
        }

        $parsed = parse_url( $src );
        if ( isset( $parsed['query'] ) && $parsed['query'] ) {
            wp_parse_str( $parsed['query']$qv );
            $url = add_query_arg( $qv$url );
        }

        return $url;
    }

    return $src;
}

/** * Prints the script queue in the HTML head on admin pages. * * Postpones the scripts that were queued for the footer. * print_footer_scripts() is called in the footer to print these scripts. * * @since 2.8.0 * * @see wp_print_scripts() * * @global bool $concatenate_scripts * * @return array */
'required'    => true,
                    ),
                    'instance'  => array(
                        'description' => __( 'Current instance settings of the widget.' ),
                        'type'        => 'object',
                    ),
                    'form_data' => array(
                        'description'       => __( 'Serialized widget form data to encode into instance settings.' ),
                        'type'              => 'string',
                        'sanitize_callback' => static function( $form_data ) {
                            $array = array();
                            wp_parse_str( $form_data$array );
                            return $array;
                        },
                    ),
                ),
                array(
                    'methods'             => WP_REST_Server::CREATABLE,
                    'permission_callback' => array( $this, 'get_item_permissions_check' ),
                    'callback'            => array( $this, 'encode_form_data' ),
                ),
            )
        );

        
if ( false === $parsed_url ) {
                $requests[] = new WP_Error( 'parse_path_failed', __( 'Could not parse the path.' ), array( 'status' => 400 ) );

                continue;
            }

            $single_request = new WP_REST_Request( isset( $args['method'] ) ? $args['method'] : 'POST', $parsed_url['path'] );

            if ( ! empty( $parsed_url['query'] ) ) {
                $query_args = null; // Satisfy linter.                 wp_parse_str( $parsed_url['query']$query_args );
                $single_request->set_query_params( $query_args );
            }

            if ( ! empty( $args['body'] ) ) {
                $single_request->set_body_params( $args['body'] );
            }

            if ( ! empty( $args['headers'] ) ) {
                $single_request->set_headers( $args['headers'] );
            }

            
if ( str_contains( $uri, '?' ) ) {
        list( $base$query ) = explode( '?', $uri, 2 );
        $base                .= '?';
    } elseif ( $protocol || ! str_contains( $uri, '=' ) ) {
        $base  = $uri . '?';
        $query = '';
    } else {
        $base  = '';
        $query = $uri;
    }

    wp_parse_str( $query$qs );
    $qs = urlencode_deep( $qs ); // This re-URL-encodes things that were already in the query string.     if ( is_array( $args[0] ) ) {
        foreach ( $args[0] as $k => $v ) {
            $qs[ $k ] = $v;
        }
    } else {
        $qs[ $args[0] ] = $args[1];
    }

    foreach ( $qs as $k => $v ) {
        if ( false === $v ) {
            
'context'     => array( 'edit' ),
                        ),
                    ),
                ),
                'form_data'     => array(
                    'description' => __( 'URL-encoded form data from the widget admin form. Used to update a widget that does not support instance. Write only.' ),
                    'type'        => 'string',
                    'context'     => array(),
                    'arg_options' => array(
                        'sanitize_callback' => static function( $form_data ) {
                            $array = array();
                            wp_parse_str( $form_data$array );
                            return $array;
                        },
                    ),
                ),
            ),
        );

        return $this->add_additional_fields_schema( $this->schema );
    }
}

    public static function from_url( $url ) {
        $bits         = parse_url( $url );
        $query_params = array();

        if ( ! empty( $bits['query'] ) ) {
            wp_parse_str( $bits['query']$query_params );
        }

        $api_root = rest_url();
        if ( get_option( 'permalink_structure' ) && str_starts_with( $url$api_root ) ) {
            // Pretty permalinks on, and URL is under the API root.             $api_url_part = substr( $urlstrlen( untrailingslashit( $api_root ) ) );
            $route        = parse_url( $api_url_part, PHP_URL_PATH );
        } elseif ( ! empty( $query_params['rest_route'] ) ) {
            // ?rest_route=... set directly.             $route = $query_params['rest_route'];
            unset( $query_params['rest_route'] );
        }
do_action( '_admin_menu' );
}

// Create list of page plugin hook names. foreach ( $menu as $menu_page ) {
    $pos = strpos( $menu_page[2], '?' );

    if ( false !== $pos ) {
        // Handle post_type=post|page|foo pages.         $hook_name = substr( $menu_page[2], 0, $pos );
        $hook_args = substr( $menu_page[2]$pos + 1 );
        wp_parse_str( $hook_args$hook_args );

        // Set the hook name to be the post type.         if ( isset( $hook_args['post_type'] ) ) {
            $hook_name = $hook_args['post_type'];
        } else {
            $hook_name = basename( $hook_name, '.php' );
        }
        unset( $hook_args );
    } else {
        $hook_name = basename( $menu_page[2], '.php' );
    }

    
Home | Imprint | This part of the site doesn't use cookies.