esc_url example



/** * Displays header image URL. * * @since 2.1.0 */
function header_image() {
    $image = get_header_image();

    if ( $image ) {
        echo esc_url( $image );
    }
}

/** * Gets the header images uploaded for the active theme. * * @since 3.2.0 * * @return array */
function get_uploaded_header_images() {
    

    $show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true );

    foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
        switch_to_blog( $blog->userblog_id );

        if ( true === $show_site_icons && has_site_icon() ) {
            $blavatar = sprintf(
                '<img class="blavatar" src="%s" srcset="%s 2x" alt="" width="16" height="16"%s />',
                esc_url( get_site_icon_url( 16 ) ),
                esc_url( get_site_icon_url( 32 ) ),
                ( wp_lazy_loading_enabled( 'img', 'site_icon_in_toolbar' ) ? ' loading="lazy"' : '' )
            );
        } else {
            $blavatar = '<div class="blavatar"></div>';
        }

        $blogname = $blog->blogname;

        if ( ! $blogname ) {
            $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
        }
if ( is_array( $comments ) && $comments ) {
            // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)             $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
            _prime_post_caches( $post_idsstrpos( get_option( 'permalink_structure' ), '%category%' ), false );

            foreach ( (array) $comments as $comment ) {
                $output .= '<li class="recentcomments">';
                $output .= sprintf(
                    /* translators: Comments widget. 1: Comment author, 2: Post link. */
                    _x( '%1$s on %2$s', 'widgets' ),
                    '<span class="comment-author-link">' . get_comment_author_link( $comment ) . '</span>',
                    '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . get_the_title( $comment->comment_post_ID ) . '</a>'
                );
                $output .= '</li>';
            }
        }
        $output .= '</ul>';

        if ( 'html5' === $format ) {
            $output .= '</nav>';
        }

        $output .= $args['after_widget'];

        
<?php echo $post_id; ?>" value="<?php echo $nonce; ?>" /> <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" /> <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" /> <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" /> <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap"> <div class="imgedit-crop-grid"></div> <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=imgedit-preview&amp;_ajax_nonce=' . $nonce . '&amp;postid=' . $post_id . '&amp;rand=' . rand( 1, 99999 ); ?>" alt="" /> </div> </div> <div class="imgedit-settings"> <div class="imgedit-tool-active"> <div class="imgedit-group"> <div id="imgedit-scale" tabindex="-1" class="imgedit-group-controls"> <div class="imgedit-group-top"> <h2><?php _e( 'Scale Image' ); ?></h2> <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"> <?php                         /* translators: Hidden accessibility text. */
                        
array(
            'class' => $css_classes . ' wp-block-navigation-item' . ( $has_submenu ? ' has-child' : '' ) .
                ( $is_active ? ' current-menu-item' : '' ),
            'style' => $style_attribute,
        )
    );
    $html               = '<li ' . $wrapper_attributes . '>' .
        '<a class="wp-block-navigation-item__content" ';

    // Start appending HTML attributes to anchor tag.     if ( isset( $attributes['url'] ) ) {
        $html .= ' href="' . esc_url( block_core_navigation_link_maybe_urldecode( $attributes['url'] ) ) . '"';
    }

    if ( $is_active ) {
        $html .= ' aria-current="page"';
    }

    if ( isset( $attributes['opensInNewTab'] ) && true === $attributes['opensInNewTab'] ) {
        $html .= ' target="_blank" ';
    }

    if ( isset( $attributes['rel'] ) ) {
        
'default'           => false,
                'sanitize_callback' => static function( $value ) {
                    return (bool) $value;
                },
            )
        );

        $description  = '<p>';
        $description .= sprintf(
            /* translators: %s: Twenty Twenty-One support article URL. */
            __( 'Dark Mode is a device setting. If a visitor to your site requests it, your site will be shown with a dark background and light text. <a href="%s">Learn more about Dark Mode.</a>', 'twentytwentyone' ),
            esc_url( __( 'https://wordpress.org/documentation/article/twenty-twenty-one/#dark-mode-support', 'twentytwentyone' ) )
        );
        $description .= '</p>';
        $description .= '<p>' . __( 'Dark Mode can also be turned on and off with a button that you can find in the bottom corner of the page.', 'twentytwentyone' ) . '</p>';

        $wp_customize->add_control(
            'respect_user_color_preference',
            array(
                'type'            => 'checkbox',
                'section'         => 'colors',
                'label'           => esc_html__( 'Dark Mode support', 'twentytwentyone' ),
                'priority'        => 110,
                
$this->l10n = array_merge(
            $this->l10n,
            array(
                'no_media_selected'          => __( 'No image selected' ),
                'add_media'                  => _x( 'Add Image', 'label for button in the image widget' ),
                'replace_media'              => _x( 'Replace Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
                'edit_media'                 => _x( 'Edit Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
                'missing_attachment'         => sprintf(
                    /* translators: %s: URL to media library. */
                    __( 'That image cannot be found. Check your <a href="%s">media library</a> and make sure it was not deleted.' ),
                    esc_url( admin_url( 'upload.php' ) )
                ),
                /* translators: %d: Widget count. */
                'media_library_state_multi'  => _n_noop( 'Image Widget (%d)', 'Image Widget (%d)' ),
                'media_library_state_single' => __( 'Image Widget' ),
            )
        );
    }

    /** * Get schema for properties of a widget instance (item). * * @since 4.8.0 * * @see WP_REST_Controller::get_item_schema() * @see WP_REST_Controller::get_additional_fields() * @link https://core.trac.wordpress.org/ticket/35574 * * @return array Schema for properties. */
<?php _ex( 'Name', 'link name' ); ?></label></h2> <div class="inside"> <input type="text" name="link_name" size="30" maxlength="255" value="<?php echo esc_attr( $link->link_name ); ?>" id="link_name" /> <p><?php _e( 'Example: Nifty blogging software' ); ?></p> </div> </div> <div id="addressdiv" class="postbox"> <h2 class="postbox-header"><label for="link_url"><?php _e( 'Web Address' ); ?></label></h2> <div class="inside"> <input type="text" name="link_url" size="30" maxlength="255" class="code" value="<?php echo esc_url( $link->link_url ); ?>" id="link_url" /> <p><?php _e( 'Example: <code>https://wordpress.org/</code> &#8212; do not forget the <code>https://</code>' ); ?></p> </div> </div> <div id="descriptiondiv" class="postbox"> <h2 class="postbox-header"><label for="link_description"><?php _e( 'Description' ); ?></label></h2> <div class="inside"> <input type="text" name="link_description" size="30" maxlength="255" value="<?php echo isset( $link->link_description ) ? esc_attr( $link->link_description ) : ''; ?>" id="link_description" /> <p><?php _e( 'This will be shown when someone hovers over the link in the blogroll, or optionally below the link.' ); ?></p> </div> </div> </div><!-- /post-body-content --> <div id="postbox-container-1" class="postbox-container">


        if ( $spammed > 0 ) {
            $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;

            $messages[] = sprintf(
                /* translators: %s: Number of comments. */
                _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ),
                $spammed
            ) . sprintf(
                ' <a href="%1$s">%2$s</a><br />',
                esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", 'bulk-comments' ) ),
                __( 'Undo' )
            );
        }

        if ( $unspammed > 0 ) {
            $messages[] = sprintf(
                /* translators: %s: Number of comments. */
                _n( '%s comment restored from the spam.', '%s comments restored from the spam.', $unspammed ),
                $unspammed
            );
        }

        
' class="%s"',
                esc_attr( $css_class )
            );

            if ( 'current' === $css_class ) {
                $aria_current = ' aria-current="page"';
            }
        }

        return sprintf(
            '<a href="%s"%s%s>%s</a>',
            esc_url( $url ),
            $class_html,
            $aria_current,
            $link_text
        );
    }

    /** * @global array $locked_post_status This seems to be deprecated. * @global array $avail_post_stati * @return array */
    

            if (
                'publish' === get_post_status( $privacy_policy_page_id )
                && current_user_can( 'edit_theme_options' )
                && current_theme_supports( 'menus' )
            ) {
                $privacy_page_updated_message = sprintf(
                    /* translators: %s: URL to Customizer -> Menus. */
                    __( 'Privacy Policy page setting updated successfully. Remember to <a href="%s">update your menus</a>!' ),
                    esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) )
                );
            }
        }

        add_settings_error( 'page_for_privacy_policy', 'page_for_privacy_policy', $privacy_page_updated_message, 'success' );
    } elseif ( 'create-privacy-page' === $action ) {

        if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
            require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
        }

        
<div class="akismet-enter-api-key-box centered"> <a href="#"><?php esc_html_e( 'Manually enter an API key', 'akismet' ); ?></a> <div class="enter-api-key"> <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post"> <?php wp_nonce_field( Akismet_Admin::NONCE ) ?> <input type="hidden" name="action" value="enter-key"> <p style="width: 100%; display: flex; flex-wrap: nowrap; box-sizing: border-box;"> <input id="key" name="key" type="text" size="15" value="" placeholder="<?php esc_attr_e( 'Enter your API key' , 'akismet' ); ?>" class="regular-text code" style="flex-grow: 1; margin-right: 1rem;"> <input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' );?>"> </p> </form> </div> </div>
require_once ABSPATH . 'wp-admin/admin-header.php';

?> <div class="privacy-settings-header"> <div class="privacy-settings-title-section"> <h1> <?php _e( 'Privacy' ); ?> </h1> </div> <nav class="privacy-settings-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> <a href="<?php echo esc_url( admin_url( 'options-privacy.php' ) ); ?>" class="privacy-settings-tab"> <?php             /* translators: Tab heading for Site Health Status page. */
            _ex( 'Settings', 'Privacy Settings' );
            ?> </a> <a href="<?php echo esc_url( admin_url( 'options-privacy.php?tab=policyguide' ) ); ?>" class="privacy-settings-tab active" aria-current="true"> <?php             /* translators: Tab heading for Site Health Status page. */
            _ex( 'Policy Guide', 'Privacy Settings' );
            ?>
'<strong>' . $theme->display( 'Name' ) . '</strong>',
                            '<em>' . $theme->display( 'Author' ) . '</em>'
                        ) . '</li>';
                    }
                    ?> </ul> <?php if ( 1 === $themes_to_delete ) : ?> <p><?php _e( 'Are you sure you want to delete this theme?' ); ?></p> <?php else : ?> <p><?php _e( 'Are you sure you want to delete these themes?' ); ?></p> <?php endif; ?> <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> <input type="hidden" name="verify-delete" value="1" /> <input type="hidden" name="action" value="delete-selected" /> <?php
                    foreach ( (array) $themes as $theme ) {
                        echo '<input type="hidden" name="checked[]" value="' . esc_attr( $theme ) . '" />';
                    }

                    wp_nonce_field( 'bulk-themes' );

                    if ( 1 === $themes_to_delete ) {
                        
<?php                 _e( 'This theme does not work with your versions of WordPress and PHP.' );
                if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
                    printf(
                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
                        self_admin_url( 'update-core.php' ),
                        esc_url( wp_get_update_php_url() )
                    );
                    wp_update_php_annotation( '</p><p><em>', '</em>' );
                } elseif ( current_user_can( 'update_core' ) ) {
                    printf(
                        /* translators: %s: URL to WordPress Updates screen. */
                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
                        self_admin_url( 'update-core.php' )
                    );
                } elseif ( current_user_can( 'update_php' ) ) {
                    printf(
                        /* translators: %s: URL to Update PHP page. */
                        
Home | Imprint | This part of the site doesn't use cookies.