• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

WordPress Security Standards want me to escape my html, but how to do it correctly?

phpwordpresselementorcodesniffer


PHP Snippet 1:

$output = "<HTML>
    <form>
        <div>
            <label>$i_am</label>
            <input type='text' name='i_am' value='' />
        </div>
        <div>
            <label>$and_i_am_looking_for</label>
            <input type='text' name='and_i_am_looking_for' value='' />
        </div>
    </form>
</HTML>";

PHP Snippet 2:

echo wp_kses(
    $output,
    array(
        'form'  => array(),
        'div'   => array(),
        'label' => array(),
        'input' => array(
            'type',
            'name',
            'value',
        ),
    )
);

Related Snippets

PHP only Hit Counter?

Symfony autowiring issues since docker update

Show date difference as "20" instead of "20 years ago"

Unable to create lockable file - Laravel 8 & PHP 8

VB.NET WebRequest with PHP POST

PHP password_verify

Extract house numbers from address string

Laravel UUID generation

Target Laravelista is not instantiable

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

Woocommerce product attributes with hierarchy like categories

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Multiply each value in array using array_map function

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

How to add automatically collapse/expand in content wordpress (single.php)?

About Contact Privacy policy Terms and conditions