Changeset 15212
- Timestamp:
- 09/17/2026 04:25:15 PM (2 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 2 added
- 21 edited
-
plugins/plugin-directory/admin/class-customizations.php (modified) (3 diffs)
-
plugins/plugin-directory/admin/metabox/class-release-confirmation.php (modified) (2 diffs)
-
plugins/plugin-directory/api/class-base.php (modified) (2 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-categorization.php (modified) (2 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-committers.php (modified) (2 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-release-confirmation.php (modified) (7 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-self-close.php (modified) (2 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-self-toggle-preview.php (modified) (2 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-self-transfer.php (modified) (2 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-support-reps.php (modified) (2 diffs)
-
plugins/plugin-directory/api/routes/class-plugin-upload.php (modified) (1 diff)
-
plugins/plugin-directory/class-template.php (modified) (8 diffs)
-
plugins/plugin-directory/js/edit-form.js (modified) (1 diff)
-
plugins/plugin-directory/shortcodes/class-upload.php (modified) (2 diffs)
-
plugins/plugin-directory/tests/Rest_Action_Nonce_Test.php (added)
-
plugins/plugin-directory/tests/Rest_Cross_Origin_Write_Test.php (added)
-
plugins/plugin-directory/widgets/class-committers.php (modified) (2 diffs)
-
plugins/plugin-directory/widgets/class-support-reps.php (modified) (2 diffs)
-
plugins/plugin-directory/widgets/js/committers.js (modified) (2 diffs)
-
plugins/plugin-directory/widgets/js/support-reps.js (modified) (2 diffs)
-
themes/pub/wporg-plugins-2024/functions.php (modified) (2 diffs)
-
themes/pub/wporg-plugins-2024/js/section-categorization.js (modified) (1 diff)
-
themes/pub/wporg-plugins-2024/js/upload.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r15188 r15212 3 3 4 4 use \WordPressdotorg\Plugin_Directory; 5 use WordPressdotorg\Plugin_Directory\API\Base; 5 6 use \WordPressdotorg\Plugin_Directory\Tools; 6 7 use \WordPressdotorg\Plugin_Directory\Tools\SVN; … … 135 136 */ 136 137 public function enqueue_assets( $hook_suffix ) { 137 global $post _type;138 global $post, $post_type; 138 139 139 140 if ( 'plugin' === $post_type ) { … … 148 149 'removeCommitterAYS' => __( 'Are you sure you want to remove this committer?', 'wporg-plugins' ), 149 150 'removeSupportRepAYS' => __( 'Are you sure you want to remove this support rep?', 'wporg-plugins' ), 151 'uploadNonce' => Base::action_nonce( 'upload', $post->ID ), 150 152 ) ); 151 153 break; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-release-confirmation.php
r15188 r15212 3 3 4 4 use WP_REST_Request; 5 use WordPressdotorg\Plugin_Directory\API\Base; 5 6 use WordPressdotorg\Plugin_Directory\Tools; 6 7 use WordPressdotorg\Plugin_Directory\Shortcodes\Release_Confirmation as Release_Confirmation_Shortcode; … … 67 68 $new 68 69 ); 70 $request->set_param( 71 Base::ACTION_NONCE_PARAM, 72 Base::action_nonce( 'enable_release_confirmation', $post->post_name ) 73 ); 69 74 70 75 // For some reason, this is causing a 502 bad gateway - upstream sent too big header -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-base.php
r14873 r15212 8 8 */ 9 9 class Base { 10 11 /** 12 * The request parameter that carries a privileged route's action nonce. 13 * 14 * Kept separate from `_wpnonce`, which core's cookie authentication claims for 15 * the generic `wp_rest` action before a route is reached. 16 * 17 * @var string 18 */ 19 const ACTION_NONCE_PARAM = '_wporg_action'; 20 10 21 /** 11 22 * Initializes REST API customizations. 12 23 */ 13 24 public static function init() { 25 add_filter( 'rest_request_before_callbacks', array( __CLASS__, 'reject_cross_origin_write' ), 10, 3 ); 26 14 27 self::load_routes(); 15 28 } … … 96 109 return true; 97 110 } 111 112 /** 113 * Mints the nonce a privileged route requires, bound to the action it authorizes. 114 * 115 * @param string $action The route action, such as `add_committer`. 116 * @param string $subject Optional. What the action is performed on, usually a plugin slug. 117 * @return string The nonce to pass as {@see Base::ACTION_NONCE_PARAM}. 118 */ 119 public static function action_nonce( $action, $subject = '' ) { 120 return wp_create_nonce( self::action_nonce_name( $action, $subject ) ); 121 } 122 123 /** 124 * Names the nonce action for a privileged route. 125 * 126 * @param string $action The route action, such as `add_committer`. 127 * @param string $subject Optional. What the action is performed on, usually a plugin slug. 128 * @return string The nonce action. 129 */ 130 protected static function action_nonce_name( $action, $subject = '' ) { 131 $subject = (string) $subject; 132 133 return 'wporg_plugins_' . $action . ( '' !== $subject ? ':' . $subject : '' ); 134 } 135 136 /** 137 * A Permission Check callback which requires the capability and action a route declares. 138 * 139 * Routes name both alongside their callback: 140 * 141 * 'permission_callback' => array( $this, 'permission_check_action' ), 142 * 'wporg_capability' => 'plugin_add_committer', 143 * 'wporg_action' => 'add_committer', 144 * 145 * The capability is checked against the request's plugin, and the nonce is bound to its 146 * slug plus any further `wporg_nonce_params` the route lists, such as a release tag. A 147 * route whose subject is not a plugin slug calls {@see Base::verify_action_nonce()} 148 * itself with whatever identifies its own. 149 * 150 * @param \WP_REST_Request $request The Rest API Request. 151 * @return bool|\WP_Error True when both hold, false or WP_Error upon failure. 152 */ 153 public function permission_check_action( $request ) { 154 $attributes = $request->get_attributes(); 155 156 // A route that declares neither is refused rather than checked against nothing. 157 if ( empty( $attributes['wporg_capability'] ) || empty( $attributes['wporg_action'] ) ) { 158 return false; 159 } 160 161 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 162 163 if ( ! $plugin || ! current_user_can( $attributes['wporg_capability'], $plugin ) ) { 164 return false; 165 } 166 167 $subject = array( $request['plugin_slug'] ); 168 169 foreach ( $attributes['wporg_nonce_params'] ?? array() as $param ) { 170 $subject[] = $request[ $param ]; 171 } 172 173 return $this->verify_action_nonce( $request, $attributes['wporg_action'], implode( ':', $subject ) ); 174 } 175 176 /** 177 * Verifies that a request carries the nonce for the action it is asking for. 178 * 179 * Returns the same error code as a stale `wp_rest` nonce, so the routes that turn 180 * that into a "link has expired" page keep doing so. 181 * 182 * @param \WP_REST_Request $request The Rest API Request. 183 * @param string $action The route action, such as `add_committer`. 184 * @param string $subject Optional. What the action is performed on. 185 * @return bool|\WP_Error True if the nonce is valid, WP_Error upon failure. 186 */ 187 public function verify_action_nonce( $request, $action, $subject = '' ) { 188 $nonce = $request->get_param( self::ACTION_NONCE_PARAM ); 189 190 if ( ! $nonce || ! wp_verify_nonce( $nonce, self::action_nonce_name( $action, $subject ) ) ) { 191 return new \WP_Error( 192 'rest_cookie_invalid_nonce', 193 __( 'Sorry! You cannot do that.', 'wporg-plugins' ), 194 array( 'status' => \WP_Http::FORBIDDEN ) 195 ); 196 } 197 198 return true; 199 } 200 201 /** 202 * Keeps a cookie-authenticated write to this namespace on the directory's own pages. 203 * 204 * The login cookie is shared across the wordpress.org hosts, so the session does not 205 * say which host a request came from; `Origin` does. 206 * 207 * Routes whose permission callback is `__return_true` are exempt, such as the 208 * blueprint Playground fetches from its own origin: the session is not what 209 * authorizes those. 210 * 211 * @param mixed $response Result to send to the client. 212 * @param array $handler Route handler used for the request. 213 * @param \WP_REST_Request $request Request used to generate the response. 214 * @return mixed The response, or WP_Error when the write came from elsewhere. 215 */ 216 public static function reject_cross_origin_write( $response, $handler, $request ) { 217 if ( null !== $response ) { 218 return $response; 219 } 220 221 if ( ! str_starts_with( strtolower( ltrim( $request->get_route(), '/' ) ), 'plugins/v1/' ) ) { 222 return $response; 223 } 224 225 if ( in_array( $request->get_method(), array( 'GET', 'HEAD', 'OPTIONS' ), true ) ) { 226 return $response; 227 } 228 229 if ( isset( $handler['permission_callback'] ) && '__return_true' === $handler['permission_callback'] ) { 230 return $response; 231 } 232 233 if ( ! is_user_logged_in() ) { 234 return $response; 235 } 236 237 $origin = get_http_origin(); 238 if ( ! $origin || in_array( $origin, self::same_site_origins(), true ) ) { 239 return $response; 240 } 241 242 return new \WP_Error( 243 'rest_cross_origin_write', 244 __( 'Sorry! You cannot do that.', 'wporg-plugins' ), 245 array( 'status' => \WP_Http::FORBIDDEN ) 246 ); 247 } 248 249 /** 250 * The origins this site's own pages are served from. 251 * 252 * Each localised directory is its own site, so `home_url()` already names the host 253 * that served the page making the request. Anything the mapping does not cover is 254 * a legitimate write refused, which is what the filter is for. 255 * 256 * @return array The origins a write may carry. 257 */ 258 protected static function same_site_origins() { 259 $origins = array(); 260 261 foreach ( array( home_url(), admin_url() ) as $url ) { 262 $parts = wp_parse_url( $url ); 263 264 if ( ! empty( $parts['scheme'] ) && ! empty( $parts['host'] ) ) { 265 $origins[] = $parts['scheme'] . '://' . $parts['host'] . 266 ( empty( $parts['port'] ) ? '' : ':' . $parts['port'] ); 267 } 268 } 269 270 /** 271 * Filters the origins a `plugins/v1` write may be made from. 272 * 273 * @param array $origins Origins serving this directory's own pages. 274 */ 275 $origins = apply_filters( 'wporg_plugins_same_site_origins', array_unique( $origins ) ); 276 277 return array_map( 'strval', (array) $origins ); 278 } 98 279 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-categorization.php
r12337 r15212 19 19 'methods' => WP_REST_Server::CREATABLE, 20 20 'callback' => [ $this, 'save_external_repository_url' ], 21 'permission_callback' => function( $request ) { 22 return current_user_can( 23 'plugin_admin_edit', 24 Plugin_Directory::get_plugin_post( $request['plugin_slug'] ) 25 ); 26 }, 21 'permission_callback' => [ $this, 'permission_check_action' ], 22 'wporg_capability' => 'plugin_admin_edit', 23 'wporg_action' => 'save_categorization', 27 24 'args' => [ 28 25 'plugin_slug' => [ … … 42 39 'methods' => WP_REST_Server::CREATABLE, 43 40 'callback' => [ $this, 'save_external_support_url' ], 44 'permission_callback' => function( $request ) { 45 return current_user_can( 46 'plugin_admin_edit', 47 Plugin_Directory::get_plugin_post( $request['plugin_slug'] ) 48 ); 49 }, 41 'permission_callback' => [ $this, 'permission_check_action' ], 42 'wporg_capability' => 'plugin_admin_edit', 43 'wporg_action' => 'save_categorization', 50 44 'args' => [ 51 45 'plugin_slug' => [ -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-committers.php
r15044 r15212 39 39 'methods' => WP_REST_Server::CREATABLE, 40 40 'callback' => array( $this, 'add_committer' ), 41 'permission_callback' => function( $request ) { 42 return current_user_can( 43 'plugin_add_committer', 44 Plugin_Directory::get_plugin_post( $request['plugin_slug'] ) 45 ); 46 }, 41 'permission_callback' => array( $this, 'permission_check_action' ), 42 'wporg_capability' => 'plugin_add_committer', 43 'wporg_action' => 'add_committer', 47 44 'args' => array( 48 45 'plugin_slug' => array( … … 57 54 'methods' => WP_REST_Server::DELETABLE, 58 55 'callback' => array( $this, 'revoke_committer' ), 59 'permission_callback' => function( $request ) { 60 return current_user_can( 61 'plugin_remove_committer', 62 Plugin_Directory::get_plugin_post( $request['plugin_slug'] ) 63 ); 64 }, 56 'permission_callback' => array( $this, 'permission_check_action' ), 57 'wporg_capability' => 'plugin_remove_committer', 58 'wporg_action' => 'remove_committer', 65 59 'args' => array( 66 60 'plugin_slug' => array( -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-release-confirmation.php
r14698 r15212 30 30 ], 31 31 ], 32 'permission_callback' => function( $request ) { 33 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 34 35 return current_user_can( 'plugin_manage_releases', $plugin ); 36 }, 32 'permission_callback' => [ $this, 'permission_check_action' ], 33 'wporg_capability' => 'plugin_manage_releases', 34 'wporg_action' => 'enable_release_confirmation', 37 35 ] ); 38 36 … … 48 46 ] 49 47 ], 50 'permission_callback' => [ $this, 'permission_can_access_plugin' ], 48 'permission_callback' => [ $this, 'permission_can_access_release' ], 49 'wporg_capability' => 'plugin_manage_releases', 50 'wporg_action' => 'confirm_release', 51 'wporg_nonce_params' => [ 'plugin_tag' ], 51 52 ] ); 52 53 … … 62 63 ] 63 64 ], 64 'permission_callback' => [ $this, 'permission_can_access_plugin' ], 65 'permission_callback' => [ $this, 'permission_can_access_release' ], 66 'wporg_capability' => 'plugin_manage_releases', 67 'wporg_action' => 'discard_release', 68 'wporg_nonce_params' => [ 'plugin_tag' ], 65 69 ] ); 66 70 … … 76 80 ] 77 81 ], 78 'permission_callback' => function( $request ) { 79 if ( current_user_can( 'plugin_review' ) ) { 80 return $this->permission_can_access_plugin( $request ); 81 } 82 83 return false; 84 }, 82 'permission_callback' => [ $this, 'permission_can_undo_discard' ], 83 'wporg_capability' => 'plugin_manage_releases', 84 'wporg_action' => 'undo_discard_release', 85 'wporg_nonce_params' => [ 'plugin_tag' ], 85 86 ] ); 86 87 … … 95 96 is_array( $result ) && isset( $result['code'] ) && 96 97 ( 97 preg_match( '!^/plugins/v1/plugin/([^/]+)/release-confirmation(/[^/]+) ?$!', $request->get_route(), $m )98 preg_match( '!^/plugins/v1/plugin/([^/]+)/release-confirmation(/[^/]+){0,2}$!', $request->get_route(), $m ) 98 99 || 99 100 '/plugins/v1/release-confirmation-access' === $request->get_route() 100 101 ) 101 102 ) { 102 if ( 'rest_cookie_invalid_nonce' == $result['code'] || 'rest_forbidden' == $result['code'] ) { 103 if ( 104 'rest_cookie_invalid_nonce' === $result['code'] || 105 'rest_forbidden' === $result['code'] || 106 'rest_cross_origin_write' === $result['code'] 107 ) { 103 108 wp_die( 'The link you have followed has expired.' ); 104 109 } … … 109 114 110 115 /** 116 * Validate that the user can manage releases for the given tag, and meant to. 117 * 118 * These routes list `plugin_tag` among their nonce params, so the token is bound to 119 * the tag as well as the plugin and one release's link does not authorize another's. 120 * The check runs before the 2FA hand-off in 121 * {@see Plugin_Release_Confirmation::permission_can_access_plugin()}, which would 122 * otherwise redirect a request this route goes on to refuse. 123 * 124 * @param \WP_REST_Request $request The Rest API Request. 125 * @return bool|\WP_Error True when both hold, false or WP_Error upon failure. 126 */ 127 public function permission_can_access_release( $request ) { 128 $verified = $this->permission_check_action( $request ); 129 130 if ( true !== $verified ) { 131 return $verified; 132 } 133 134 return $this->permission_can_access_plugin( $request ); 135 } 136 137 /** 138 * Validate that a reviewer can undo the discarding of the given release. 139 * 140 * @param \WP_REST_Request $request The Rest API Request. 141 * @return bool|\WP_Error True when the reviewer may, false or WP_Error upon failure. 142 */ 143 public function permission_can_undo_discard( $request ) { 144 if ( ! current_user_can( 'plugin_review' ) ) { 145 return false; 146 } 147 148 return $this->permission_can_access_release( $request ); 149 } 150 151 /** 152 * Whether the current user may manage the requested plugin's releases. 153 * 154 * @param \WP_REST_Request $request The Rest API Request. 155 * @return bool True if the plugin exists and the user may manage its releases. 156 */ 157 protected function can_manage_releases( $request ) { 158 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 159 160 return $plugin && current_user_can( 'plugin_manage_releases', $plugin ); 161 } 162 163 /** 111 164 * Validate that the user can manage releases for the given plugin. 165 * 166 * @param \WP_REST_Request $request The Rest API Request. 167 * @return bool True if the user may manage the plugin's releases. 112 168 */ 113 169 public function permission_can_access_plugin( $request ) { 114 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 115 116 if ( ! $plugin || ! current_user_can( 'plugin_manage_releases', $plugin ) ) { 170 if ( ! $this->can_manage_releases( $request ) ) { 117 171 return false; 118 172 } … … 130 184 // Before we say no, check if the user just needs to validate their 2FA. 131 185 if ( $status && $status['needs_revalidate'] && 'GET' === $request->get_method() ) { 186 // The route's own nonce has to survive the trip through revalidation. 132 187 $current_rest_url = add_query_arg( 133 188 array( 134 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 135 '_wp_http_referer' => wp_get_referer(), 189 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 190 '_wp_http_referer' => wp_get_referer(), 191 self::ACTION_NONCE_PARAM => $request->get_param( self::ACTION_NONCE_PARAM ), 136 192 ), 137 193 get_rest_url( null, $request->get_route() ) -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-self-close.php
r12180 r15212 23 23 ], 24 24 ], 25 'permission_callback' => function( $request ) { 26 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 27 28 return current_user_can( 'plugin_self_close', $plugin ); 29 }, 25 'permission_callback' => [ $this, 'permission_check_action' ], 26 'wporg_capability' => 'plugin_self_close', 27 'wporg_action' => 'self_close', 30 28 ] ); 31 29 … … 43 41 if ( 'rest_cookie_invalid_nonce' == $result['code'] ) { 44 42 wp_die( 'The link you have followed has expired.' ); 45 } elseif ( 'rest_forbidden' == $result['code'] ) {43 } elseif ( 'rest_forbidden' === $result['code'] || 'rest_cross_origin_write' === $result['code'] ) { 46 44 wp_die( "Sorry, You can't do that." ); 47 45 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-self-toggle-preview.php
r14305 r15212 23 23 ], 24 24 ], 25 'permission_callback' => function( $request ) { 26 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 27 28 return current_user_can( 'plugin_toggle_public_preview', $plugin ); 29 }, 25 'permission_callback' => [ $this, 'permission_check_action' ], 26 'wporg_capability' => 'plugin_toggle_public_preview', 27 'wporg_action' => 'self_toggle_preview', 30 28 ] ); 31 29 … … 43 41 if ( 'rest_cookie_invalid_nonce' == $result['code'] ) { 44 42 wp_die( 'The link you have followed has expired.' ); 45 } elseif ( 'rest_forbidden' == $result['code'] ) {43 } elseif ( 'rest_forbidden' === $result['code'] || 'rest_cross_origin_write' === $result['code'] ) { 46 44 wp_die( "Sorry, You can't do that." ); 47 45 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-self-transfer.php
r11744 r15212 28 28 ] 29 29 ], 30 'permission_callback' => function( $request ) { 31 $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 32 33 return current_user_can( 'plugin_self_transfer', $plugin ); 34 }, 30 'permission_callback' => [ $this, 'permission_check_action' ], 31 'wporg_capability' => 'plugin_self_transfer', 32 'wporg_action' => 'self_transfer', 35 33 ] ); 36 34 … … 48 46 if ( 'rest_cookie_invalid_nonce' == $result['code'] ) { 49 47 wp_die( 'The link you have followed has expired.' ); 50 } elseif ( 'rest_forbidden' == $result['code'] ) {48 } elseif ( 'rest_forbidden' === $result['code'] || 'rest_cross_origin_write' === $result['code'] ) { 51 49 wp_die( "Sorry, You can't do that." ); 52 50 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-support-reps.php
r11373 r15212 39 39 'methods' => WP_REST_Server::CREATABLE, 40 40 'callback' => array( $this, 'add_support_rep' ), 41 'permission_callback' => function( $request ) { 42 return current_user_can( 43 'plugin_add_support_rep', 44 Plugin_Directory::get_plugin_post( $request['plugin_slug'] ) 45 ); 46 }, 41 'permission_callback' => array( $this, 'permission_check_action' ), 42 'wporg_capability' => 'plugin_add_support_rep', 43 'wporg_action' => 'add_support_rep', 47 44 'args' => array( 48 45 'plugin_slug' => array( … … 57 54 'methods' => WP_REST_Server::DELETABLE, 58 55 'callback' => array( $this, 'remove_support_rep' ), 59 'permission_callback' => function( $request ) { 60 return current_user_can( 61 'plugin_remove_support_rep', 62 Plugin_Directory::get_plugin_post( $request['plugin_slug'] ) 63 ); 64 }, 56 'permission_callback' => array( $this, 'permission_check_action' ), 57 'wporg_capability' => 'plugin_remove_support_rep', 58 'wporg_action' => 'remove_support_rep', 65 59 'args' => array( 66 60 'plugin_slug' => array( -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-upload.php
r15166 r15212 60 60 } 61 61 62 return true;62 return $this->verify_action_nonce( $request, 'upload', $post->ID ); 63 63 } 64 64 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r15190 r15212 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 4 use WordPressdotorg\Plugin_Directory\API\Base; 3 5 4 6 // Explicitly require dependencies so this file can be sourced outside the Plugin Directory. … … 949 951 950 952 return add_query_arg( 951 array( '_wpnonce' => wp_create_nonce( 'wp_rest' ) ), 953 array( 954 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 955 Base::ACTION_NONCE_PARAM => Base::action_nonce( 'self_close', $post->post_name ), 956 ), 952 957 home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/self-close' ) 953 958 ); … … 964 969 965 970 return add_query_arg( 966 array( '_wpnonce' => wp_create_nonce( 'wp_rest' ) ), 971 array( 972 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 973 Base::ACTION_NONCE_PARAM => Base::action_nonce( 'self_transfer', $post->post_name ), 974 ), 967 975 home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/self-transfer' ) 968 976 ); … … 979 987 980 988 return add_query_arg( 981 array( '_wpnonce' => wp_create_nonce( 'wp_rest' ) ), 989 array( 990 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 991 Base::ACTION_NONCE_PARAM => Base::action_nonce( 'self_toggle_preview', $post->post_name ), 992 ), 982 993 home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/self-toggle-preview' ) 983 994 ); … … 994 1005 995 1006 return add_query_arg( 996 array( '_wpnonce' => wp_create_nonce( 'wp_rest' ), 'dismiss' => 1 ), 1007 array( 1008 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 1009 Base::ACTION_NONCE_PARAM => Base::action_nonce( 'self_toggle_preview', $post->post_name ), 1010 'dismiss' => 1, 1011 ), 997 1012 home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/self-toggle-preview' ) 998 1013 ); … … 1009 1024 1010 1025 return add_query_arg( 1011 array( '_wpnonce' => wp_create_nonce( 'wp_rest' ) ), 1026 array( 1027 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 1028 Base::ACTION_NONCE_PARAM => Base::action_nonce( 'enable_release_confirmation', $post->post_name ), 1029 ), 1012 1030 home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/release-confirmation' ) 1013 1031 ); … … 1027 1045 if ( 'approve' === $what ) { 1028 1046 $endpoint = 'plugin/%s/release-confirmation/%s'; 1047 $action = 'confirm_release'; 1029 1048 } elseif ( 'discard' === $what ) { 1030 1049 $endpoint = 'plugin/%s/release-confirmation/%s/discard'; 1050 $action = 'discard_release'; 1031 1051 } elseif ( 'undo-discard' === $what ) { 1032 1052 $endpoint = 'plugin/%s/release-confirmation/%s/undo-discard'; 1053 $action = 'undo_discard_release'; 1033 1054 } else { 1034 1055 return ''; … … 1038 1059 1039 1060 return add_query_arg( 1040 array( '_wpnonce' => wp_create_nonce( 'wp_rest' ) ), 1061 array( 1062 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 1063 Base::ACTION_NONCE_PARAM => Base::action_nonce( $action, $post->post_name . ':' . $tag ), 1064 ), 1041 1065 $url 1042 1066 ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js
r14779 r15212 210 210 data.append( $file.prop( 'name' ), file_input.files[0] ); 211 211 data.append( 'admin', true ); 212 data.append( '_wporg_action', pluginDirectory.uploadNonce ); 212 213 213 214 wp.apiRequest( { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php
r15188 r15212 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 use WordPressdotorg\Plugin_Directory\API\Base; 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 use function WordPressdotorg\Two_Factor\get_onboarding_account_url; … … 306 307 <input type="hidden" name="action" value="request-slug-change" /> 307 308 <input type="hidden" name="id" value="<?php echo esc_attr( $plugin->ID ); ?>" /> 309 <input type="hidden" name="<?php echo esc_attr( Base::ACTION_NONCE_PARAM ); ?>" value="<?php echo esc_attr( Base::action_nonce( 'upload', $plugin->ID ) ); ?>" /> 308 310 309 311 <div class="notice notice-info notice-alt"> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-committers.php
r15188 r15212 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 3 4 use WordPressdotorg\Plugin_Directory\API\Base; 4 5 use WordPressdotorg\Plugin_Directory\Tools; 5 6 … … 39 40 'restUrl' => get_rest_url(), 40 41 'restNonce' => wp_create_nonce( 'wp_rest' ), 42 'addNonce' => Base::action_nonce( 'add_committer', $post->post_name ), 43 'removeNonce' => Base::action_nonce( 'remove_committer', $post->post_name ), 41 44 'pluginSlug' => $post->post_name, 42 45 'removeCommitterAYS' => __( 'Are you sure you want to remove %s as a committer?', 'wporg-plugins' ), -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support-reps.php
r15188 r15212 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 3 4 use WordPressdotorg\Plugin_Directory\API\Base; 4 5 use WordPressdotorg\Plugin_Directory\Tools; 5 6 … … 40 41 'restUrl' => get_rest_url(), 41 42 'restNonce' => wp_create_nonce( 'wp_rest' ), 43 'addNonce' => Base::action_nonce( 'add_support_rep', $post->post_name ), 44 'removeNonce' => Base::action_nonce( 'remove_support_rep', $post->post_name ), 42 45 'pluginSlug' => $post->post_name, 43 46 'removeSupportRepAYS' => __( 'Are you sure you want to remove %s as a support rep?', 'wporg-plugins' ), -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/js/committers.js
r13633 r15212 38 38 $this.addClass( 'spinner' ); 39 39 40 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/committers/' + user_id + '/?_wpnonce=' + pluginDir.restNonce; 40 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/committers/' + user_id + '/?_wpnonce=' + pluginDir.restNonce 41 + '&_wporg_action=' + pluginDir.removeNonce; 41 42 42 43 $.post( { … … 57 58 $newUserInput = $row.find( 'input[name="committer"]' ), 58 59 $button = $row.find( '.button-small' ).addClass( 'spinner' ), 59 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/committers/?_wpnonce=' + pluginDir.restNonce; 60 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/committers/?_wpnonce=' + pluginDir.restNonce 61 + '&_wporg_action=' + pluginDir.addNonce; 60 62 61 63 $.post( { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/js/support-reps.js
r13633 r15212 38 38 $this.addClass( 'spinner' ); 39 39 40 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/support-reps/' + user_id + '/?_wpnonce=' + pluginDir.restNonce; 40 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/support-reps/' + user_id + '/?_wpnonce=' + pluginDir.restNonce 41 + '&_wporg_action=' + pluginDir.removeNonce; 41 42 42 43 $.post( { … … 57 58 $newUserInput = $row.find( 'input[name="support_rep"]' ), 58 59 $button = $row.find( '.button-small' ).addClass( 'spinner' ), 59 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/support-reps/?_wpnonce=' + pluginDir.restNonce; 60 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/support-reps/?_wpnonce=' + pluginDir.restNonce 61 + '&_wporg_action=' + pluginDir.addNonce; 60 62 61 63 $.post( { -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php
r15109 r15212 10 10 namespace WordPressdotorg\Plugin_Directory\Theme; 11 11 12 use WordPressdotorg\Plugin_Directory\API\Base; 12 13 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 13 14 use WordPressdotorg\Plugin_Directory\Template; … … 110 111 wp_enqueue_script( 'wporg-plugins-categorization', get_stylesheet_directory_uri() . '/js/section-categorization.js', array( 'jquery' ), filemtime( __DIR__ . '/js/section-categorization.js' ), true ); 111 112 wp_localize_script( 'wporg-plugins-categorization', 'categorizationOptions', [ 112 'restUrl' => get_rest_url(), 113 'restNonce' => wp_create_nonce( 'wp_rest' ), 114 'pluginSlug' => $post->post_name, 113 'restUrl' => get_rest_url(), 114 'restNonce' => wp_create_nonce( 'wp_rest' ), 115 'actionNonce' => Base::action_nonce( 'save_categorization', $post->post_name ), 116 'pluginSlug' => $post->post_name, 115 117 ] ); 116 118 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/section-categorization.js
r12346 r15212 34 34 let fieldInput = form.querySelector( 'input[name="' + field_name + '"]' ), 35 35 button = form.querySelector( '.button-small' )?.classList.add( 'spinner' ), 36 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/' + form.id + '/?_wpnonce=' + pluginDir.restNonce; 36 url = pluginDir.restUrl + 'plugins/v1/plugin/' + pluginDir.pluginSlug + '/' + form.id + '/?_wpnonce=' + pluginDir.restNonce 37 + '&_wporg_action=' + pluginDir.actionNonce, 37 38 originalValue = fieldInput.dataset.originalValue ?? ''; 38 39 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/upload.js
r14979 r15212 14 14 type: 'PATCH', 15 15 data: { 16 post_name: slug 16 post_name: slug, 17 _wporg_action: $form.find('input[name="_wporg_action"]').val() 17 18 } 18 19 } )
Note:
See TracChangeset
for help on using the changeset viewer.