Make WordPress Core

Ticket #59547: 59547.diff

File 59547.diff, 3.8 KB (added by SergeyBiryukov, 8 months ago)
  • src/wp-includes/html-api/class-wp-html-processor.php

     
    3939 *
    4040 * Example:
    4141 *
    42  *     $processor = WP_HTML_Processor::createFragment( $html );
     42 *     $processor = WP_HTML_Processor::create_fragment( $html );
    4343 *     if ( $processor->next_tag( array( 'breadcrumbs' => array( 'DIV', 'FIGURE', 'IMG' ) ) ) ) {
    4444 *         $processor->add_class( 'responsive-image' );
    4545 *     }
     
    5858 * Since all elements find themselves inside a full HTML document
    5959 * when parsed, the return value from `get_breadcrumbs()` will always
    6060 * contain any implicit outermost elements. For example, when parsing
    61  * with `createFragment()` in the `BODY` context (the default), any
     61 * with `create_fragment()` in the `BODY` context (the default), any
    6262 * tag in the given HTML document will contain `array( 'HTML', 'BODY', … )`
    6363 * in its breadcrumbs.
    6464 *
     
    239239         * @param string $encoding Text encoding of the document; must be default of 'UTF-8'.
    240240         * @return WP_HTML_Processor|null The created processor if successful, otherwise null.
    241241         */
    242         public static function createFragment( $html, $context = '<body>', $encoding = 'UTF-8' ) {
     242        public static function create_fragment( $html, $context = '<body>', $encoding = 'UTF-8' ) {
    243243                if ( '<body>' !== $context || 'UTF-8' !== $encoding ) {
    244244                        return null;
    245245                }
     
    280280         *
    281281         * @since 6.4.0
    282282         *
    283          * @see WP_HTML_Processor::createFragment()
     283         * @see WP_HTML_Processor::create_fragment()
    284284         *
    285285         * @param string      $html                                  HTML to process.
    286286         * @param string|null $use_the_static_create_methods_instead This constructor should not be called manually.
     
    292292                        _doing_it_wrong(
    293293                                __METHOD__,
    294294                                sprintf(
    295                                         /* translators: %s: WP_HTML_Processor::createFragment. */
     295                                        /* translators: %s: WP_HTML_Processor::create_fragment(). */
    296296                                        __( 'Call %s to create an HTML Processor instead of calling the constructor directly.' ),
    297                                         '<code>WP_HTML_Processor::createFragment</code>'
     297                                        '<code>WP_HTML_Processor::create_fragment()</code>'
    298298                                ),
    299299                                '6.4.0'
    300300                        );
     
    324324         *
    325325         * Example
    326326         *
    327          *     $processor = WP_HTML_Processor::createFragment( '<template><strong><button><em><p><em>' );
     327         *     $processor = WP_HTML_Processor::create_fragment( '<template><strong><button><em><p><em>' );
    328328         *     false === $processor->next_tag();
    329329         *     WP_HTML_Processor::ERROR_UNSUPPORTED === $processor->get_last_error();
    330330         *
     
    428428         *
    429429         * Example:
    430430         *
    431          *     $processor = WP_HTML_Processor::createFragment( '<div><span><figure><img></figure></span></div>' );
     431         *     $processor = WP_HTML_Processor::create_fragment( '<div><span><figure><img></figure></span></div>' );
    432432         *     $processor->next_tag( 'img' );
    433433         *     true  === $processor->matches_breadcrumbs( array( 'figure', 'img' ) );
    434434         *     true  === $processor->matches_breadcrumbs( array( 'span', 'figure', 'img' ) );
     
    557557         *
    558558         * Example
    559559         *
    560          *     $processor = WP_HTML_Processor::createFragment( '<p><strong><em><img></em></strong></p>' );
     560         *     $processor = WP_HTML_Processor::create_fragment( '<p><strong><em><img></em></strong></p>' );
    561561         *     $processor->next_tag( 'IMG' );
    562562         *     $processor->get_breadcrumbs() === array( 'HTML', 'BODY', 'P', 'STRONG', 'EM', 'IMG' );
    563563         *
     
    14391439         *
    14401440         * @access private
    14411441         */
    1442         const CONSTRUCTOR_UNLOCK_CODE = 'Use WP_HTML_Processor::createFragment instead of calling the class constructor directly.';
     1442        const CONSTRUCTOR_UNLOCK_CODE = 'Use WP_HTML_Processor::create_fragment() instead of calling the class constructor directly.';
    14431443}