html_entity_decode example

class Tokenizer implements TokenizerInterface
{
    /** * @internal */
    public function __construct(private readonly int $tokenMinimumLength)
    {
    }

    public function tokenize(string $string): array
    {
        $string = mb_strtolower(html_entity_decode($string), 'UTF-8');
        $string = trim(str_replace(['.', '/', '\\'], ' ', $string));
        $string = str_replace('<', ' <', $string);
        $string = strip_tags($string);
        $string = trim((string) preg_replace("/[^\pL\-_0-9]/u", ' ', $string));

        $tags = explode(' ', $string);

        $filtered = [];
        foreach ($tags as $tag) {
            $tag = trim($tag);

            
 ')+'
            . ')'
        . ")\\1#",
        $content,
        $post_links
    );

    $post_links = array_unique(
        array_map(
            static function( $link ) {
                // Decode to replace valid entities, like &amp;.                 $link = html_entity_decode( $link );
                // Maintain backward compatibility by removing extraneous semi-colons (`;`).                 return str_replace( ';', '', $link );
            },
            $post_links[2]
        )
    );

    return array_values( $post_links );
}

/** * Checks content for video and audio links to add as enclosures. * * Will not add enclosures that have already been added and will * remove enclosures that are no longer in the post. This is called as * pingbacks and trackbacks. * * @since 1.5.0 * @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was * updated to accept a post ID or a WP_Post object. * @since 5.6.0 The `$content` parameter is no longer optional, but passing `null` to skip it * is still supported. * * @global wpdb $wpdb WordPress database abstraction object. * * @param string|null $content Post content. If `null`, the `post_content` field from `$post` is used. * @param int|WP_Post $post Post ID or post object. * @return void|false Void on success, false if the post is not found. */

                '5.7.0'
            );

            if ( false === $l10n ) {
                // This should really not be needed, but is necessary for backward compatibility.                 $l10n = array( $l10n );
            }
        }

        if ( is_string( $l10n ) ) {
            $l10n = html_entity_decode( $l10n, ENT_QUOTES, 'UTF-8' );
        } elseif ( is_array( $l10n ) ) {
            foreach ( $l10n as $key => $value ) {
                if ( ! is_scalar( $value ) ) {
                    continue;
                }

                $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
            }
        }

        $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';

        

  public function providerTestPhpTransliteration() {
    $random_generator = new Random();
    $random = $random_generator->string(10);
    // Make some strings with two, three, and four-byte characters for testing.     // Note that the 3-byte character is overridden by the 'kg' language.     // cSpell:disable-next-line     $two_byte = 'Ä Ö Ü Å Ø äöüåøhello';
    // This is a Cyrillic character that looks something like a "u". See     // http://www.unicode.org/charts/PDF/U0400.pdf     $three_byte = html_entity_decode('&#x446;', ENT_NOQUOTES, 'UTF-8');
    // This is a Canadian Aboriginal character like a triangle. See     // http://www.unicode.org/charts/PDF/U1400.pdf     $four_byte = html_entity_decode('&#x1411;', ENT_NOQUOTES, 'UTF-8');
    // These are two Gothic alphabet letters. See     // http://wikipedia.org/wiki/Gothic_alphabet     // They are not in our tables, but should at least give us '?' (unknown).     $five_byte = html_entity_decode('&#x10330;&#x10338;', ENT_NOQUOTES, 'UTF-8');

    // cSpell:disable     return [
      // Each test case is language code, input, output, unknown character, max
 '', $this->getContent());
      // Filter out all HTML tags, as they are not visible in a normal browser.       $text = strip_tags($raw_content);
      // To preserve BC and match \Behat\Mink\Element\Element::getText() include       // the page title.       $title_element = $this->find('css', 'title');
      if ($title_element) {
        $text = $title_element->getText() . ' ' . $text;
      }
      // To match what the user sees and \Behat\Mink\Element\Element::getText()       // decode HTML entities.       $text = html_entity_decode($text, ENT_QUOTES);
      // To match \Behat\Mink\Element\Element::getText() remove new lines and       // normalize spaces.       $text = str_replace("\n", ' ', $text);
      $text = preg_replace('/ {2,}/', ' ', $text);
      return trim($text);
    }

    // If using a real browser fallback to the \Behat\Mink\Element\Element     // implementation.     return parent::getText();
  }

  

        );

        /* * Gather all strings in PHP that may be needed by JS on the client. * Once JS i18n is implemented (in #20491), this can be removed. */
        $some_non_rendered_areas_messages    = array();
        $some_non_rendered_areas_messages[1] = html_entity_decode(
            __( 'Your theme has 1 other widget area, but this particular page does not display it.' ),
            ENT_QUOTES,
            get_bloginfo( 'charset' )
        );
        $registered_sidebar_count            = count( $wp_registered_sidebars );
        for ( $non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count$non_rendered_count++ ) {
            $some_non_rendered_areas_messages[ $non_rendered_count ] = html_entity_decode(
                sprintf(
                    /* translators: %s: The number of other widget areas registered but not rendered. */
                    _n(
                        'Your theme has %s other widget area, but this particular page does not display it.',
                        
if (empty($string)) {
            return [];
        }
        if ($this->replaceUmlauts) {
            $string = str_replace(
                ['Ü', 'ü', 'ä', 'Ä', 'ö', 'Ö', 'ß'],
                ['Ue', 'ue', 'ae', 'Ae', 'oe', 'Oe', 'ss'],
                $string
            );
        }

        $string = mb_strtolower(html_entity_decode($string), 'UTF-8');

        if ($this->replaceNonLetters) {
            // Remove not required chars from string             $string = trim((string) preg_replace("/[^\pL_0-9]/u", ' ', $string));
        }

        // Parse string into array         $wordsTmp = preg_split('/ /', $string, -1, PREG_SPLIT_NO_EMPTY);
        if (!\is_array($wordsTmp)) {
            return [];
        }

        
$request = $parameters;
                $query = [];
                break;
            default:
                $request = [];
                $query = $parameters;
                break;
        }

        $queryString = '';
        if (isset($components['query'])) {
            parse_str(html_entity_decode($components['query'])$qs);

            if ($query) {
                $query = array_replace($qs$query);
                $queryString = http_build_query($query, '', '&');
            } else {
                $query = $qs;
                $queryString = $components['query'];
            }
        } elseif ($query) {
            $queryString = http_build_query($query, '', '&');
        }

        

    public function get_document_title_template() {
        if ( $this->is_theme_active() ) {
            /* translators: %s: Document title from the preview. */
            $document_title_tmpl = __( 'Customize: %s' );
        } else {
            /* translators: %s: Document title from the preview. */
            $document_title_tmpl = __( 'Live Preview: %s' );
        }
        $document_title_tmpl = html_entity_decode( $document_title_tmpl, ENT_QUOTES, 'UTF-8' ); // Because exported to JS and assigned to document.title.         return $document_title_tmpl;
    }

    /** * Sets the initial URL to be previewed. * * URL is validated. * * @since 4.4.0 * * @param string $preview_url URL to be previewed. */
$future_events = array();

        foreach ( $events as $event ) {
            /* * The API's `date` and `end_date` fields are in the _event's_ local timezone, but UTC is needed so * it can be converted to the _user's_ local time. */
            $end_time = (int) $event['end_unix_timestamp'];

            if ( time() < $end_time ) {
                // Decode HTML entities from the event title.                 $event['title'] = html_entity_decode( $event['title'], ENT_QUOTES, 'UTF-8' );

                array_push( $future_events$event );
            }
        }

        $future_wordcamps = array_filter(
            $future_events,
            static function( $wordcamp ) {
                return 'wordcamp' === $wordcamp['type'];
            }
        );

        
$post_title = sprintf( __( '#%d (no title)' )$post->ID );
                }

                $post_type_label = get_post_type_object( $post->post_type )->labels->singular_name;
                $post_states     = get_post_states( $post );
                if ( ! empty( $post_states ) ) {
                    $post_type_label = implode( ',', $post_states );
                }

                $items[] = array(
                    'id'         => "post-{$post->ID}",
                    'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
                    'type'       => 'post_type',
                    'type_label' => $post_type_label,
                    'object'     => $post->post_type,
                    'object_id'  => (int) $post->ID,
                    'url'        => get_permalink( (int) $post->ID ),
                );
            }
        } elseif ( 'taxonomy' === $object_type ) {
            $terms = get_terms(
                array(
                    'taxonomy'     => $object_name,
                    
$view->displayHandlers->get('default')->options['fields'][$this->fieldStorages[5]->getName()]['settings'] = [
      'trim_length' => 3,
    ];
    $view->preview();

    // Make sure that the formatter works as expected.     // @todo Add a specific formatter in #3046722.     // @see https://www.drupal.org/project/drupal/issues/3046722     for ($i = 0; $i < 2; $i++) {
      $field_name = $this->fieldStorages[5]->getName();
      $rendered_field = $view->style_plugin->getField($i$field_name);
      $this->assertEquals(3, strlen(html_entity_decode($rendered_field)));
    }
  }

  /** * Tests multi-value field rendering. */
  public function doTestMultipleFieldRender() {
    $view = Views::getView('test_view_fieldapi');
    $field_name = $this->fieldStorages[3]->getName();

    // Test delta limit.
$metaDescription = $view->getAssign('sArticle')['metaDescription'];
            } elseif (!empty($view->getAssign('sArticle')['description'])) {
                $metaDescription = $view->getAssign('sArticle')['description'];
            } elseif (!empty($view->getAssign('sArticle')['description_long'])) {
                $metaDescription = $view->getAssign('sArticle')['description_long'];
            } elseif (!empty($view->getAssign('sCategoryContent')['metaDescription'])) {
                $metaDescription = $view->getAssign('sCategoryContent')['metaDescription'];
            } elseif (!empty($view->getAssign('sCategoryContent')['cmstext'])) {
                $metaDescription = $view->getAssign('sCategoryContent')['cmstext'];
            }
            if (!empty($metaDescription)) {
                $metaDescription = html_entity_decode($metaDescription, ENT_COMPAT, 'UTF-8');
                $metaDescription = trim((string) preg_replace('/\s\s+/', ' ', strip_tags($metaDescription)));
                $metaDescription = htmlspecialchars($metaDescription, ENT_COMPAT);
            }
        }

        $controller = $request->getControllerName();

        if ($request->get('action') === 'manufacturer' && $request->get('controller') === 'listing') {
            $alias = $mapper->getQueryAliases();

            if (\array_key_exists('sSupplier', $alias) && ($index = array_search($alias['sSupplier']$queryBlacklist, true))) {
                
throw new Enlight_Exception('##sOrder-sTemporaryOrder-#01: No rows affected or no order id saved', 0);
        }

        // Create order attributes         $this->attributePersister->persist($this->orderAttributes, 's_order_attributes', $orderID);

        foreach ($this->sBasketData[CartKey::POSITIONS] as $basketRow) {
            if (!$basketRow['price']) {
                $basketRow['price'] = '0,00';
            }

            $basketRow['articlename'] = html_entity_decode($basketRow['articlename']);
            $basketRow['articlename'] = strip_tags($basketRow['articlename']);

            $basketRow['articlename'] = $this->sSYSTEM->sMODULES['sArticles']->sOptimizeText($basketRow['articlename']);

            if (!$basketRow['esdarticle']) {
                $basketRow['esdarticle'] = '0';
            }
            if (!$basketRow['modus']) {
                $basketRow['modus'] = '0';
            }
            if (!$basketRow['taxID']) {
                

        $mce_translation = apply_filters( 'wp_mce_translation', $mce_translation$mce_locale );

        foreach ( $mce_translation as $key => $value ) {
            // Remove strings that are not translated.             if ( $key === $value ) {
                unset( $mce_translation[ $key ] );
                continue;
            }

            if ( str_contains( $value, '&' ) ) {
                $mce_translation[ $key ] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' );
            }
        }

        // Set direction.         if ( is_rtl() ) {
            $mce_translation['_dir'] = 'rtl';
        }

        if ( $json_only ) {
            return wp_json_encode( $mce_translation );
        }

        
Home | Imprint | This part of the site doesn't use cookies.