Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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/src/wp-admin/admin-ajax.php

    r41978 r42343  
    2626
    2727// Require an action parameter
    28 if ( empty( $_REQUEST['action'] ) )
     28if ( empty( $_REQUEST['action'] ) ) {
    2929    wp_die( '0', 400 );
     30}
    3031
    3132/** Load WordPress Administration APIs */
     
    4546
    4647$core_actions_get = array(
    47     'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
    48     'autocomplete-user', 'dashboard-widgets', 'logged-in',
     48    'fetch-list',
     49    'ajax-tag-search',
     50    'wp-compression-test',
     51    'imgedit-preview',
     52    'oembed-cache',
     53    'autocomplete-user',
     54    'dashboard-widgets',
     55    'logged-in',
    4956);
    5057
    5158$core_actions_post = array(
    52     'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
    53     'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
    54     'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
    55     'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'closed-postboxes',
    56     'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
    57     'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
    58     'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
    59     'save-widget', 'delete-inactive-widgets', 'set-post-thumbnail', 'date_format', 'time_format',
    60     'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
    61     'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
    62     'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
    63     'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
    64     'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'crop-image',
    65     'generate-password', 'save-wporg-username', 'delete-plugin', 'search-plugins',
    66     'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 'install-theme',
    67     'get-post-thumbnail-html', 'get-community-events', 'edit-theme-plugin-file',
     59    'oembed-cache',
     60    'image-editor',
     61    'delete-comment',
     62    'delete-tag',
     63    'delete-link',
     64    'delete-meta',
     65    'delete-post',
     66    'trash-post',
     67    'untrash-post',
     68    'delete-page',
     69    'dim-comment',
     70    'add-link-category',
     71    'add-tag',
     72    'get-tagcloud',
     73    'get-comments',
     74    'replyto-comment',
     75    'edit-comment',
     76    'add-menu-item',
     77    'add-meta',
     78    'add-user',
     79    'closed-postboxes',
     80    'hidden-columns',
     81    'update-welcome-panel',
     82    'menu-get-metabox',
     83    'wp-link-ajax',
     84    'menu-locations-save',
     85    'menu-quick-search',
     86    'meta-box-order',
     87    'get-permalink',
     88    'sample-permalink',
     89    'inline-save',
     90    'inline-save-tax',
     91    'find_posts',
     92    'widgets-order',
     93    'save-widget',
     94    'delete-inactive-widgets',
     95    'set-post-thumbnail',
     96    'date_format',
     97    'time_format',
     98    'wp-remove-post-lock',
     99    'dismiss-wp-pointer',
     100    'upload-attachment',
     101    'get-attachment',
     102    'query-attachments',
     103    'save-attachment',
     104    'save-attachment-compat',
     105    'send-link-to-editor',
     106    'send-attachment-to-editor',
     107    'save-attachment-order',
     108    'heartbeat',
     109    'get-revision-diffs',
     110    'save-user-color-scheme',
     111    'update-widget',
     112    'query-themes',
     113    'parse-embed',
     114    'set-attachment-thumbnail',
     115    'parse-media-shortcode',
     116    'destroy-sessions',
     117    'install-plugin',
     118    'update-plugin',
     119    'crop-image',
     120    'generate-password',
     121    'save-wporg-username',
     122    'delete-plugin',
     123    'search-plugins',
     124    'search-install-plugins',
     125    'activate-plugin',
     126    'update-theme',
     127    'delete-theme',
     128    'install-theme',
     129    'get-post-thumbnail-html',
     130    'get-community-events',
     131    'edit-theme-plugin-file',
    68132);
    69133
    70134// Deprecated
    71135$core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-save-post', 'press-this-add-category' );
    72 $core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated );
     136$core_actions_post            = array_merge( $core_actions_post, $core_actions_post_deprecated );
    73137
    74138// Register core Ajax calls.
    75 if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
     139if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) ) {
    76140    add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );
     141}
    77142
    78 if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
     143if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) ) {
    79144    add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
     145}
    80146
    81147add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
Note: See TracChangeset for help on using the changeset viewer.