Changeset 3794418 for tokenforge/trunk/includes/class-rest.php
- Timestamp:
- 11/10/2026 12:51:32 PM (6 days ago)
- File:
-
- 1 edited
-
tokenforge/trunk/includes/class-rest.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tokenforge/trunk/includes/class-rest.php
r3784841 r3794418 34 34 35 35 /** 36 * Permission callback for routes that write free CSS values and selectors: 37 * on multisite also edit_css, as core asks for Additional CSS. 38 * 39 * @return bool 40 */ 41 public function can_write_css() { 42 return current_user_can( 'manage_options' ) && ( ! is_multisite() || current_user_can( 'edit_css' ) ); 43 } 44 45 /** 36 46 * Register routes. 37 47 * … … 39 49 */ 40 50 public function routes() { 41 $perm = array( $this, 'can_manage' ); 51 $perm = array( $this, 'can_manage' ); 52 $css_perm = array( $this, 'can_write_css' ); 42 53 // Font files land in uploads: also needs the right to upload files. 43 54 $font_perm = function () { … … 142 153 array( 143 154 'methods' => 'POST', 144 'permission_callback' => $ perm,155 'permission_callback' => $css_perm, 145 156 'callback' => array( $this, 'save' ), 146 157 ) … … 174 185 array( 175 186 'methods' => 'POST', 176 'permission_callback' => $ perm,187 'permission_callback' => $css_perm, 177 188 'callback' => array( $this, 'import_file' ), 178 189 ) … … 194 205 array( 195 206 'methods' => 'POST', 196 'permission_callback' => $ perm,207 'permission_callback' => $css_perm, 197 208 'callback' => array( Token_Files::class, 'rest_import' ), 198 209 ) … … 244 255 array( 245 256 'methods' => 'POST', 246 'permission_callback' => $ perm,257 'permission_callback' => $css_perm, 247 258 'callback' => array( $this, 'restore' ), 248 259 ) … … 869 880 * A fingerprint of a token list (same list, same fingerprint). 870 881 * 871 * @param array $ listNormalised tokens.882 * @param array $items Normalised tokens. 872 883 * @return string 873 884 */ 874 private static function tokens_rev( $ list) {875 return md5( (string) wp_json_encode( $ list) );885 private static function tokens_rev( $items ) { 886 return md5( (string) wp_json_encode( $items ) ); 876 887 } 877 888
Note:
See TracChangeset
for help on using the changeset viewer.