esc_js example

<title><?php echo esc_html( $admin_title ); ?></title> <?php
wp_enqueue_style( 'colors' );
wp_enqueue_script( 'utils' );
wp_enqueue_script( 'svg-painter' );

$admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
?> <script type="text/javascript"> addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(function(){func();});else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>', pagenow = '<?php echo esc_js( $current_screen->id ); ?>', typenow = '<?php echo esc_js( $current_screen->post_type ); ?>', adminpage = '<?php echo esc_js( $admin_body_class ); ?>', thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>', decimalPoint = '<?php echo esc_js( $wp_locale->number_format['decimal_point'] ); ?>', isRtl = <?php echo (int) is_rtl(); ?>; </script> <?php
/** * Fires when enqueuing scripts for all admin pages. * * @since 2.8.0 * * @param string $hook_suffix The current admin page. */
$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
            ?> <option value=""><?php echo esc_html( $label ); ?></option> <?php wp_get_archives( $dropdown_args ); ?> </select> <script<?php echo $type_attr; ?>> /* <![CDATA[ */ (function() { var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" ); function onSelectChange() { if ( dropdown.options[ dropdown.selectedIndex ].value !== '' ) { document.location.href = this.options[ this.selectedIndex ].value; } } dropdown.onchange = onSelectChange; })(); /* ]]> */ </script> <?php         } else {
            
array(
                            'thumbnail' => __( 'Thumbnail' ),
                            'medium'    => __( 'Medium' ),
                            'large'     => __( 'Large' ),
                            'full'      => __( 'Full Size' ),
                        )
                    );

                    foreach ( $sizes as $value => $name ) :
                        ?> <# var size = data.sizes['<?php echo esc_js( $value ); ?>']; if ( size ) { #> <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>> <?php echo esc_html( $name ); ?> &ndash; {{ size.width }} &times; {{ size.height }} </option> <# } #> <?php endforeach; ?> </select> </span> <# } #> </script>

function js_escape( $text ) {
    _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' );
    return esc_js( $text );
}

/** * Legacy escaping for HTML blocks. * * @deprecated 2.8.0 Use esc_html() * @see esc_html() * * @param string $text Text to escape. * @param string $quote_style Unused. * @param false|string $charset Unused. * @param false $double_encode Whether to double encode. Unused. * @return string Escaped `$text`. */
public function js_1() {
        $default_color = '';
        if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {
            $default_color = get_theme_support( 'custom-header', 'default-text-color' );
            if ( $default_color && ! str_contains( $default_color, '#' ) ) {
                $default_color = '#' . $default_color;
            }
        }
        ?> <script type="text/javascript"> (function($){ var default_color = '<?php echo esc_js( $default_color ); ?>', header_text_fields; function pickColor(color) { $('#name').css('color', color); $('#desc').css('color', color); $('#text-color').val(color); } function toggle_text() { var checked = $('#display-header-text').prop('checked'), text_color; header_text_fields.toggle( checked ); if ( ! checked ) return; text_color = $('#text-color'); if ( '' === text_color.val().replace('#', '') ) { text_color.val( default_color ); pickColor( default_color ); } else { pickColor( text_color.val() ); } } $( function() { var text_color = $('#text-color'); header_text_fields = $('.displaying-header-text'); text_color.wpColorPicker({ change: function( event, ui ) { pickColor( text_color.wpColorPicker('color') ); }, clear: function() { pickColor( '' ); } }); $('#display-header-text').click( toggle_text );
$_wp_additional_image_sizes = wp_get_additional_image_sizes();

    $return  = new stdClass();
    $success = false;
    $delete  = false;
    $scaled  = false;
    $nocrop  = false;
    $post    = get_post( $post_id );

    $img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) );
    if ( is_wp_error( $img ) ) {
        $return->error = esc_js( __( 'Unable to create new image.' ) );
        return $return;
    }

    $fwidth  = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
    $fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
    $target  = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
    $scale   = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];

    /** This filter is documented in wp-admin/includes/image-edit.php */
    $edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );

    
/** * Outputs and enqueues default scripts and styles for playlists. * * @since 3.9.0 * * @param string $type Type of playlist. Accepts 'audio' or 'video'. */
function wp_playlist_scripts( $type ) {
    wp_enqueue_style( 'wp-mediaelement' );
    wp_enqueue_script( 'wp-playlist' );
    ?> <!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ); ?>');</script><![endif]--> <?php     add_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
    add_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 );
}

/** * Builds the Playlist shortcode output. * * This implements the functionality of the playlist shortcode for displaying * a collection of WordPress audio or video files in a post. * * @since 3.9.0 * * @global int $content_width * * @param array $attr { * Array of default playlist attributes. * * @type string $type Type of playlist to display. Accepts 'audio' or 'video'. Default 'audio'. * @type string $order Designates ascending or descending order of items in the playlist. * Accepts 'ASC', 'DESC'. Default 'ASC'. * @type string $orderby Any column, or columns, to sort the playlist. If $ids are * passed, this defaults to the order of the $ids array ('post__in'). * Otherwise default is 'menu_order ID'. * @type int $id If an explicit $ids array is not present, this parameter * will determine which attachments are used for the playlist. * Default is the current post ID. * @type array $ids Create a playlist out of these explicit attachment IDs. If empty, * a playlist will be created from all $type attachments of $id. * Default empty. * @type array $exclude List of specific attachment IDs to exclude from the playlist. Default empty. * @type string $style Playlist style to use. Accepts 'light' or 'dark'. Default 'light'. * @type bool $tracklist Whether to show or hide the playlist. Default true. * @type bool $tracknumbers Whether to show or hide the numbers next to entries in the playlist. Default true. * @type bool $images Show or hide the video or audio thumbnail (Featured Image/post * thumbnail). Default true. * @type bool $artists Whether to show or hide artist name in the playlist. Default true. * } * * @return string Playlist output. Empty string if the passed type is unsupported. */
<?php     /** This action is documented in wp-admin/includes/meta-boxes.php */
    do_action( 'post_submitbox_start', null );
    ?> <div id="delete-action"> <?php     if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) {
        printf(
            '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>',
            wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ),
            /* translators: %s: Link name. */
            esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." )$link->link_name ) ),
            __( 'Delete' )
        );
    }
    ?> </div> <div id="publishing-action"> <?php if ( ! empty( $link->link_id ) ) { ?> <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update Link' ); ?>" /> <?php } else { ?> <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Add Link' ); ?>" />

function dismissed_updates() {
    $dismissed = get_core_updates(
        array(
            'dismissed' => true,
            'available' => false,
        )
    );

    if ( $dismissed ) {
        $show_text = esc_js( __( 'Show hidden updates' ) );
        $hide_text = esc_js( __( 'Hide hidden updates' ) );
        ?> <script type="text/javascript"> jQuery( function( $ ) { $( '#show-dismissed' ).on( 'click', function() { var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) ); if ( isExpanded ) { $( this ).text( '<?php echo $show_text; ?>' ).attr( 'aria-expanded', 'false' ); } else { $( this ).text( '<?php echo $hide_text; ?>' ).attr( 'aria-expanded', 'true' ); } $( '#dismissed-updates' ).toggle( 'fast' ); }); }); </script>

            wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args$instance ) );

            echo '</form>';

            $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
            ?> <script<?php echo $type_attr; ?>> /* <![CDATA[ */ (function() { var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" ); function onCatChange() { if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { dropdown.parentNode.submit(); } } dropdown.onchange = onCatChange; })(); /* ]]> */ </script> <?php

    } elseif ( 'db' === $context ) {
        /** This filter is documented in wp-includes/post.php */
        $value = apply_filters( "pre_{$field}", $value );
    } else {
        /** This filter is documented in wp-includes/post.php */
        $value = apply_filters( "{$field}", $value$bookmark_id$context );

        if ( 'attribute' === $context ) {
            $value = esc_attr( $value );
        } elseif ( 'js' === $context ) {
            $value = esc_js( $value );
        }
    }

    // Restore the type for integer fields after esc_attr().     if ( in_array( $field$int_fields, true ) ) {
        $value = (int) $value;
    }

    return $value;
}

// Check callback name for 'media'.     if (
        ( is_array( $content_func ) && ! empty( $content_func[1] ) && str_starts_with( (string) $content_func[1], 'media' ) ) ||
        ( ! is_array( $content_func ) && str_starts_with( $content_func, 'media' ) )
    ) {
        wp_enqueue_style( 'deprecated-media' );
    }

    ?> <script type="text/javascript"> addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(function(){func();});else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup', isRtl = <?php echo (int) is_rtl(); ?>; </script> <?php     /** This action is documented in wp-admin/admin-header.php */
    do_action( 'admin_enqueue_scripts', 'media-upload-popup' );

    /** * Fires when admin styles enqueued for the legacy (pre-3.5.0) media upload popup are printed. * * @since 2.9.0 */
    

            $value = apply_filters( "{$field}", $value$post_id$context );
        } else {
            $value = apply_filters( "post_{$field}", $value$post_id$context );
        }

        if ( 'attribute' === $context ) {
            $value = esc_attr( $value );
        } elseif ( 'js' === $context ) {
            $value = esc_js( $value );
        }
    }

    // Restore the type for integer fields after esc_attr().     if ( in_array( $field$int_fields, true ) ) {
        $value = (int) $value;
    }

    return $value;
}

/** * Prints thickbox image paths for Network Admin. * * @since 3.1.0 * * @access private */
function _thickbox_path_admin_subfolder() {
    ?> <script type="text/javascript"> var tb_pathToImage = "<?php echo esc_js( includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ) ); ?>"; </script> <?php }

/** * @param array $users * @return bool */
function confirm_delete_users( $users ) {
    $current_user = wp_get_current_user();
    if ( ! is_array( $users ) || empty( $users ) ) {
        
// Restores the more descriptive, specific name for use within this method.         $link      = $item;
        $edit_link = get_edit_bookmark_link( $link );

        $actions           = array();
        $actions['edit']   = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
        $actions['delete'] = sprintf(
            '<a class="submitdelete" href="%s" onclick="return confirm( \'%s\' );">%s</a>',
            wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ),
            /* translators: %s: Link name. */
            esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." )$link->link_name ) ),
            __( 'Delete' )
        );

        return $this->row_actions( $actions );
    }
}
Home | Imprint | This part of the site doesn't use cookies.