Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r46612 r47122  
    5454        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
    5555
    56         // No scripts left to print
     56        // No scripts left to print.
    5757        $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
    5858    }
     
    8282     */
    8383    public function test_protocols() {
    84         // Init
     84        // Init.
    8585        global $wp_scripts;
    8686        $base_url_backup      = $wp_scripts->base_url;
     
    8989        $ver                  = get_bloginfo( 'version' );
    9090
    91         // Try with an HTTP reference
     91        // Try with an HTTP reference.
    9292        wp_enqueue_script( 'jquery-http', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
    9393        $expected .= "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
    9494
    95         // Try with an HTTPS reference
     95        // Try with an HTTPS reference.
    9696        wp_enqueue_script( 'jquery-https', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
    9797        $expected .= "<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
    9898
    99         // Try with an automatic protocol reference (//)
     99        // Try with an automatic protocol reference (//).
    100100        wp_enqueue_script( 'jquery-doubleslash', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
    101101        $expected .= "<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
    102102
    103         // Try with a local resource and an automatic protocol reference (//)
     103        // Try with a local resource and an automatic protocol reference (//).
    104104        $url = '//my_plugin/script.js';
    105105        wp_enqueue_script( 'plugin-script', $url );
    106106        $expected .= "<script type='text/javascript' src='$url?ver=$ver'></script>\n";
    107107
    108         // Try with a bad protocol
     108        // Try with a bad protocol.
    109109        wp_enqueue_script( 'jquery-ftp', 'ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
    110110        $expected .= "<script type='text/javascript' src='{$wp_scripts->base_url}ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n";
     
    113113        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
    114114
    115         // No scripts left to print
     115        // No scripts left to print.
    116116        $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
    117117
    118         // Cleanup
     118        // Cleanup.
    119119        $wp_scripts->base_url = $base_url_backup;
    120120    }
     
    148148     */
    149149    function test_wp_script_add_data_with_data_key() {
    150         // Enqueue & add data
     150        // Enqueue and add data.
    151151        wp_enqueue_script( 'test-only-data', 'example.com', array(), null );
    152152        wp_script_add_data( 'test-only-data', 'data', 'testing' );
     
    157157        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
    158158
    159         // No scripts left to print
     159        // No scripts left to print.
    160160        $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
    161161    }
     
    167167     */
    168168    function test_wp_script_add_data_with_conditional_key() {
    169         // Enqueue & add conditional comments
     169        // Enqueue and add conditional comments.
    170170        wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null );
    171171        wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' );
     
    175175        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
    176176
    177         // No scripts left to print
     177        // No scripts left to print.
    178178        $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
    179179    }
     
    185185     */
    186186    function test_wp_script_add_data_with_data_and_conditional_keys() {
    187         // Enqueue & add data plus conditional comments for both
     187        // Enqueue and add data plus conditional comments for both.
    188188        wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null );
    189189        wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' );
     
    195195        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
    196196
    197         // No scripts left to print
     197        // No scripts left to print.
    198198        $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
    199199    }
     
    205205     */
    206206    function test_wp_script_add_data_with_invalid_key() {
    207         // Enqueue & add an invalid key
     207        // Enqueue and add an invalid key.
    208208        wp_enqueue_script( 'test-invalid', 'example.com', array(), null );
    209209        wp_script_add_data( 'test-invalid', 'invalid', 'testing' );
     
    213213        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
    214214
    215         // No scripts left to print
     215        // No scripts left to print.
    216216        $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
    217217    }
     
    311311     */
    312312    function test_wp_register_script_with_dependencies_in_head_and_footer() {
    313         wp_register_script( 'parent', '/parent.js', array( 'child-head' ), null, true ); // in footer
    314         wp_register_script( 'child-head', '/child-head.js', array( 'child-footer' ), null, false ); // in head
    315         wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // in footer
     313        wp_register_script( 'parent', '/parent.js', array( 'child-head' ), null, true );            // In footer.
     314        wp_register_script( 'child-head', '/child-head.js', array( 'child-footer' ), null, false ); // In head.
     315        wp_register_script( 'child-footer', '/child-footer.js', array(), null, true );              // In footer.
    316316
    317317        wp_enqueue_script( 'parent' );
     
    332332     */
    333333    function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order() {
    334         wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // in head
    335         wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // in footer
    336         wp_register_script( 'parent', '/parent.js', array( 'child-head', 'child-footer' ), null, true ); // in footer
     334        wp_register_script( 'child-head', '/child-head.js', array(), null, false );                      // In head.
     335        wp_register_script( 'child-footer', '/child-footer.js', array(), null, true );                   // In footer.
     336        wp_register_script( 'parent', '/parent.js', array( 'child-head', 'child-footer' ), null, true ); // In footer.
    337337
    338338        wp_enqueue_script( 'parent' );
     
    353353     */
    354354    function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order_and_two_parent_scripts() {
    355         wp_register_script( 'grandchild-head', '/grandchild-head.js', array(), null, false ); // in head
    356         wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // in head
    357         wp_register_script( 'child-footer', '/child-footer.js', array( 'grandchild-head' ), null, true ); // in footer
    358         wp_register_script( 'child2-head', '/child2-head.js', array(), null, false ); // in head
    359         wp_register_script( 'child2-footer', '/child2-footer.js', array(), null, true ); // in footer
    360         wp_register_script( 'parent-footer', '/parent-footer.js', array( 'child-head', 'child-footer', 'child2-head', 'child2-footer' ), null, true ); // in footer
    361         wp_register_script( 'parent-header', '/parent-header.js', array( 'child-head' ), null, false ); // in head
     355        wp_register_script( 'grandchild-head', '/grandchild-head.js', array(), null, false );             // In head.
     356        wp_register_script( 'child-head', '/child-head.js', array(), null, false );                       // In head.
     357        wp_register_script( 'child-footer', '/child-footer.js', array( 'grandchild-head' ), null, true ); // In footer.
     358        wp_register_script( 'child2-head', '/child2-head.js', array(), null, false );                     // In head.
     359        wp_register_script( 'child2-footer', '/child2-footer.js', array(), null, true );                  // In footer.
     360        wp_register_script( 'parent-footer', '/parent-footer.js', array( 'child-head', 'child-footer', 'child2-head', 'child2-footer' ), null, true ); // In footer.
     361        wp_register_script( 'parent-header', '/parent-header.js', array( 'child-head' ), null, false );   // In head.
    362362
    363363        wp_enqueue_script( 'parent-footer' );
     
    598598
    599599        $wp_scripts->do_concat    = true;
    600         $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php
     600        $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php.
    601601
    602602        $expected_localized  = "<!--[if gte IE 9]>\n";
     
    783783
    784784        $wp_scripts->do_concat    = true;
    785         $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php
     785        $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php.
    786786
    787787        wp_enqueue_script( 'one', '/wp-includes/js/script.js' );
     
    808808
    809809        $wp_scripts->do_concat    = true;
    810         $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php
     810        $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php.
    811811
    812812        wp_enqueue_script( 'one', '/wp-includes/js/script.js' );
Note: See TracChangeset for help on using the changeset viewer.