Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-ajax.php

    r41970 r42343  
    1919    /**
    2020     * Last AJAX response.  This is set via echo -or- wp_die.
     21     *
    2122     * @var string
    2223     */
     
    2526    /**
    2627     * List of ajax actions called via GET
     28     *
    2729     * @var array
    2830     */
    2931    protected static $_core_actions_get = array(
    30         'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
    31         'autocomplete-user', 'dashboard-widgets', 'logged-in',
     32        'fetch-list',
     33        'ajax-tag-search',
     34        'wp-compression-test',
     35        'imgedit-preview',
     36        'oembed-cache',
     37        'autocomplete-user',
     38        'dashboard-widgets',
     39        'logged-in',
    3240    );
    3341
    3442    /**
    3543     * Saved error reporting level
     44     *
    3645     * @var int
    3746     */
     
    4049    /**
    4150     * List of ajax actions called via POST
     51     *
    4252     * @var array
    4353     */
    4454    protected static $_core_actions_post = array(
    45         'oembed_cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
    46         'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
    47         'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
    48         'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'closed-postboxes',
    49         'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
    50         'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
    51         'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
    52         'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
    53         'wp-remove-post-lock', 'dismiss-wp-pointer', 'send-attachment-to-editor', 'heartbeat', 'nopriv_heartbeat', 'get-revision-diffs',
    54         'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
    55         'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post',
    56         'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username', 'delete-plugin',
    57         'search-plugins', 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme',
    58         'install-theme', 'get-post-thumbnail-html',
     55        'oembed_cache',
     56        'image-editor',
     57        'delete-comment',
     58        'delete-tag',
     59        'delete-link',
     60        'delete-meta',
     61        'delete-post',
     62        'trash-post',
     63        'untrash-post',
     64        'delete-page',
     65        'dim-comment',
     66        'add-link-category',
     67        'add-tag',
     68        'get-tagcloud',
     69        'get-comments',
     70        'replyto-comment',
     71        'edit-comment',
     72        'add-menu-item',
     73        'add-meta',
     74        'add-user',
     75        'closed-postboxes',
     76        'hidden-columns',
     77        'update-welcome-panel',
     78        'menu-get-metabox',
     79        'wp-link-ajax',
     80        'menu-locations-save',
     81        'menu-quick-search',
     82        'meta-box-order',
     83        'get-permalink',
     84        'sample-permalink',
     85        'inline-save',
     86        'inline-save-tax',
     87        'find_posts',
     88        'widgets-order',
     89        'save-widget',
     90        'set-post-thumbnail',
     91        'date_format',
     92        'time_format',
     93        'wp-fullscreen-save-post',
     94        'wp-remove-post-lock',
     95        'dismiss-wp-pointer',
     96        'send-attachment-to-editor',
     97        'heartbeat',
     98        'nopriv_heartbeat',
     99        'get-revision-diffs',
     100        'save-user-color-scheme',
     101        'update-widget',
     102        'query-themes',
     103        'parse-embed',
     104        'set-attachment-thumbnail',
     105        'parse-media-shortcode',
     106        'destroy-sessions',
     107        'install-plugin',
     108        'update-plugin',
     109        'press-this-save-post',
     110        'press-this-add-category',
     111        'crop-image',
     112        'generate-password',
     113        'save-wporg-username',
     114        'delete-plugin',
     115        'search-plugins',
     116        'search-install-plugins',
     117        'activate-plugin',
     118        'update-theme',
     119        'delete-theme',
     120        'install-theme',
     121        'get-post-thumbnail-html',
    59122    );
    60123
     
    104167        parent::tearDown();
    105168        $_POST = array();
    106         $_GET = array();
     169        $_GET  = array();
    107170        unset( $GLOBALS['post'] );
    108171        unset( $GLOBALS['comment'] );
     
    118181    public function logout() {
    119182        unset( $GLOBALS['current_user'] );
    120         $cookies = array(AUTH_COOKIE, SECURE_AUTH_COOKIE, LOGGED_IN_COOKIE, USER_COOKIE, PASS_COOKIE);
    121         foreach ( $cookies as $c )
    122             unset( $_COOKIE[$c] );
     183        $cookies = array( AUTH_COOKIE, SECURE_AUTH_COOKIE, LOGGED_IN_COOKIE, USER_COOKIE, PASS_COOKIE );
     184        foreach ( $cookies as $c ) {
     185            unset( $_COOKIE[ $c ] );
     186        }
    123187    }
    124188
    125189    /**
    126190     * Return our callback handler
     191     *
    127192     * @return callback
    128193     */
     
    144209     * $this->setExpectedException( 'WPAjaxDieContinueException', 'something contained in $message' );
    145210     * </code>
     211     *
    146212     * @param string $message
    147213     */
     
    163229     * Switch between user roles
    164230     * E.g. administrator, editor, author, contributor, subscriber
     231     *
    165232     * @param string $role
    166233     */
    167234    protected function _setRole( $role ) {
    168         $post = $_POST;
     235        $post    = $_POST;
    169236        $user_id = self::factory()->user->create( array( 'role' => $role ) );
    170237        wp_set_current_user( $user_id );
    171         $_POST = array_merge($_POST, $post);
     238        $_POST = array_merge( $_POST, $post );
    172239    }
    173240
     
    176243     * Capture the output via output buffering, and if there is any, store
    177244     * it in $this->_last_response.
     245     *
    178246     * @param string $action
    179247     */
     
    195263        // Save the output
    196264        $buffer = ob_get_clean();
    197         if ( !empty( $buffer ) )
     265        if ( ! empty( $buffer ) ) {
    198266            $this->_last_response = $buffer;
     267        }
    199268    }
    200269}
Note: See TracChangeset for help on using the changeset viewer.