add_query_arg example


    public function add_rule( $regex$query$after = 'bottom' ) {
        if ( is_array( $query ) ) {
            $external = false;
            $query    = add_query_arg( $query, 'index.php' );
        } else {
            $index = ! str_contains( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' );
            $front = substr( $query, 0, $index );

            $external = $front !== $this->index;
        }

        // "external" = it doesn't correspond to index.php.         if ( $external ) {
            $this->add_external_rule( $regex$query );
        } else {
            
require_once ABSPATH . WPINC . '/pluggable.php';
        }

        $validated = $this->key_service->validate_recovery_mode_key( $_GET['rm_token']$_GET['rm_key']$ttl );

        if ( is_wp_error( $validated ) ) {
            wp_die( $validated, '' );
        }

        $this->cookie_service->set_cookie();

        $url = add_query_arg( 'action', self::LOGIN_ACTION_ENTERED, wp_login_url() );
        wp_redirect( $url );
        die;
    }

    /** * Gets a URL to begin recovery mode. * * @since 5.2.0 * * @param string $token Recovery Mode token created by {@see generate_recovery_mode_token()}. * @param string $key Recovery Mode key created by {@see generate_and_store_recovery_mode_key()}. * @return string Recovery mode begin URL. */

function _post_format_link( $link$term$taxonomy ) {
    global $wp_rewrite;
    if ( 'post_format' !== $taxonomy ) {
        return $link;
    }
    if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) {
        return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug )$link );
    } else {
        $link = remove_query_arg( 'post_format', $link );
        return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug )$link );
    }
}

/** * Remove the post format prefix from the name property of the term object created by get_term(). * * @access private * @since 3.1.0 * * @param object $term * @return object */
continue;
        }

        $src = $scripts->registered[ $handle ]->src;
        $ver = $scripts->registered[ $handle ]->ver;

        if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && str_starts_with( $src$scripts->content_url ) ) ) {
            $src = $scripts->base_url . $src;
        }

        if ( ! empty( $ver ) ) {
            $src = add_query_arg( 'ver', $ver$src );
        }

        /** This filter is documented in wp-includes/class-wp-scripts.php */
        $src = esc_url( apply_filters( 'script_loader_src', $src$handle ) );

        if ( ! $src ) {
            continue;
        }

        $polyfill .= (
            // Test presence of feature...
if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) {
    check_admin_referer( 'add-user', '_wpnonce_add-user' );

    $user_details = null;
    $user_email   = wp_unslash( $_REQUEST['email'] );
    if ( str_contains( $user_email, '@' ) ) {
        $user_details = get_user_by( 'email', $user_email );
    } else {
        if ( current_user_can( 'manage_network_users' ) ) {
            $user_details = get_user_by( 'login', $user_email );
        } else {
            wp_redirect( add_query_arg( array( 'update' => 'enter_email' ), 'user-new.php' ) );
            die();
        }
    }

    if ( ! $user_details ) {
        wp_redirect( add_query_arg( array( 'update' => 'does_not_exist' ), 'user-new.php' ) );
        die();
    }

    if ( ! current_user_can( 'promote_user', $user_details->ID ) ) {
        wp_die(
            
/** This filter is documented in wp-admin/media-upload.php */
            $current = apply_filters( 'media_upload_default_tab', $default );
        }

        foreach ( $tabs as $callback => $text ) {
            $class = '';

            if ( $current == $callback ) {
                $class = " class='current'";
            }

            $href = add_query_arg(
                array(
                    'tab'            => $callback,
                    's'              => false,
                    'paged'          => false,
                    'post_mime_type' => false,
                    'm'              => false,
                )
            );
            $link = "<a href='" . esc_url( $href ) . "'$class>$text</a>";
            echo "\t<li id='" . esc_attr( "tab-$callback) . "'>$link</li>\n";
        }

        

    protected function prepare_links( $sidebar ) {
        return array(
            'collection'               => array(
                'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
            ),
            'self'                     => array(
                'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $sidebar['id'] ) ),
            ),
            'https://api.w.org/widget' => array(
                'href'       => add_query_arg( 'sidebar', $sidebar['id']rest_url( '/wp/v2/widgets' ) ),
                'embeddable' => true,
            ),
        );
    }

    /** * Retrieves the block type' schema, conforming to JSON Schema. * * @since 5.8.0 * * @return array Item schema data. */

function wp_logout_url( $redirect = '' ) {
    $args = array();
    if ( ! empty( $redirect ) ) {
        $args['redirect_to'] = urlencode( $redirect );
    }

    $logout_url = add_query_arg( $argssite_url( 'wp-login.php?action=logout', 'login' ) );
    $logout_url = wp_nonce_url( $logout_url, 'log-out' );

    /** * Filters the logout URL. * * @since 2.8.0 * * @param string $logout_url The HTML-encoded logout URL. * @param string $redirect Path to redirect to on logout. */
    return apply_filters( 'logout_url', $logout_url$redirect );
}
$can_restore = current_user_can( 'edit_post', $post->ID );
    $current_id  = false;

    foreach ( $revisions as $revision ) {
        $modified     = strtotime( $revision->post_modified );
        $modified_gmt = strtotime( $revision->post_modified_gmt . ' +0000' );
        if ( $can_restore ) {
            $restore_link = str_replace(
                '&amp;',
                '&',
                wp_nonce_url(
                    add_query_arg(
                        array(
                            'revision' => $revision->ID,
                            'action'   => 'restore',
                        ),
                        admin_url( 'revision.php' )
                    ),
                    "restore-post_{$revision->ID}"
                )
            );
        }

        
if ( ! empty( $_GET['remind_me_later'] ) ) {
            if ( ! wp_verify_nonce( $_GET['remind_me_later'], 'remind_me_later_nonce' ) ) {
                wp_safe_redirect( wp_login_url() );
                exit;
            }

            if ( $remind_interval > 0 ) {
                update_option( 'admin_email_lifespan', time() + $remind_interval );
            }

            $redirect_to = add_query_arg( 'admin_email_remind_later', 1, $redirect_to );
            wp_safe_redirect( $redirect_to );
            exit;
        }

        if ( ! empty( $_POST['correct-admin-email'] ) ) {
            if ( ! check_admin_referer( 'confirm_admin_email', 'confirm_admin_email_nonce' ) ) {
                wp_safe_redirect( wp_login_url() );
                exit;
            }

            /** * Filters the interval for redirecting the user to the admin email confirmation screen. * * If `0` (zero) is returned, the user will not be redirected. * * @since 5.3.0 * * @param int $interval Interval time (in seconds). Default is 6 months. */


        $theme_info = $this->upgrader->theme_info();
        if ( empty( $theme_info ) ) {
            return;
        }

        $name       = $theme_info->display( 'Name' );
        $stylesheet = $this->upgrader->result['destination_name'];
        $template   = $theme_info->get_template();

        $activate_link = add_query_arg(
            array(
                'action'     => 'activate',
                'template'   => urlencode( $template ),
                'stylesheet' => urlencode( $stylesheet ),
            ),
            admin_url( 'themes.php' )
        );
        $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );

        $install_actions = array();

        
wp_redirect( network_admin_url( 'plugin-install.php' ) );
    exit;
}

$wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table' );
$pagenum       = $wp_list_table->get_pagenum();

if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
    $location = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );

    if ( ! empty( $_REQUEST['paged'] ) ) {
        $location = add_query_arg( 'paged', (int) $_REQUEST['paged']$location );
    }

    wp_redirect( $location );
    exit;
}

$wp_list_table->prepare_items();

$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );

if ( $pagenum > $total_pages && $total_pages > 0 ) {
    
$show_option_all = '';
    if ( $optionall )
        $show_option_all = $all;

    $show_option_none = '';
    if ( $optionnone )
        $show_option_none = __('None');

    $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
                    'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
    $query = add_query_arg($vars, '');
    return wp_dropdown_categories($query);
}

/** * Lists authors. * * @since 1.2.0 * @deprecated 2.1.0 Use wp_list_authors() * @see wp_list_authors() * * @param bool $optioncount * @param bool $exclude_admin * @param bool $show_fullname * @param bool $hide_empty * @param string $feed * @param string $feed_image * @return null|string */
$url .= $path;
    } else {
        $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
        /* * nginx only allows HTTP/1.0 methods when redirecting from / to /index.php. * To work around this, we manually add index.php to the URL, avoiding the redirect. */
        if ( ! str_ends_with( $url, 'index.php' ) ) {
            $url .= 'index.php';
        }

        $url = add_query_arg( 'rest_route', $path$url );
    }

    if ( is_ssl() && isset( $_SERVER['SERVER_NAME'] ) ) {
        // If the current host is the same as the REST URL host, force the REST URL scheme to HTTPS.         if ( parse_url( get_home_url( $blog_id ), PHP_URL_HOST ) === $_SERVER['SERVER_NAME'] ) {
            $url = set_url_scheme( $url, 'https' );
        }
    }

    if ( is_admin() && force_ssl_admin() ) {
        /* * In this situation the home URL may be http:, and `is_ssl()` may be false, * but the admin is served over https: (one way or another), so REST API usage * will be blocked by browsers unless it is also served over HTTPS. */

function _wp_link_page( $i ) {
    global $wp_rewrite;
    $post       = get_post();
    $query_args = array();

    if ( 1 == $i ) {
        $url = get_permalink();
    } else {
        if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) {
            $url = add_query_arg( 'page', $iget_permalink() );
        } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
            $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
        } else {
            $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' );
        }
    }

    if ( is_preview() ) {

        if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id']$_GET['preview_nonce'] ) ) {
            $query_args['preview_id']    = wp_unslash( $_GET['preview_id'] );
            
Home | Imprint | This part of the site doesn't use cookies.