AMP_Blacklist_Sanitizer::sanitize_a_attribute PHP Метод

sanitize_a_attribute() приватный Метод

private sanitize_a_attribute ( $node, $attribute )
    private function sanitize_a_attribute($node, $attribute)
    {
        $attribute_name = strtolower($attribute->name);
        if ('rel' === $attribute_name) {
            $old_value = $attribute->value;
            $new_value = trim(preg_replace(self::PATTERN_REL_WP_ATTACHMENT, '', $old_value));
            if (empty($new_value)) {
                $node->removeAttribute($attribute_name);
            } elseif ($old_value !== $new_value) {
                $node->setAttribute($attribute_name, $new_value);
            }
        } elseif ('rev' === $attribute_name) {
            // rev removed from HTML5 spec, which was used by Jetpack Markdown.
            $node->removeAttribute($attribute_name);
        } elseif ('target' === $attribute_name) {
            // _blank is the only allowed value and it must be lowercase.
            // replace _new with _blank and others should simply be removed.
            $old_value = strtolower($attribute->value);
            if ('_blank' === $old_value || '_new' === $old_value) {
                // _new is not allowed; swap with _blank
                $node->setAttribute($attribute_name, '_blank');
            } else {
                // only _blank is allowed
                $node->removeAttribute($attribute_name);
            }
        }
    }