Plugin Directory


Ignore:
Timestamp:
11/10/2026 12:51:32 PM (6 days ago)
Author:
pristadigital
Message:

Release 0.55.0: flex grids, utility class families, breakpoint variants, security fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tokenforge/trunk/includes/class-rest.php

    r3784841 r3794418  
    3434
    3535        /**
     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        /**
    3646         * Register routes.
    3747         *
    … …  
    3949         */
    4050        public function routes() {
    41                 $perm = array( $this, 'can_manage' );
     51                $perm     = array( $this, 'can_manage' );
     52                $css_perm = array( $this, 'can_write_css' );
    4253                // Font files land in uploads: also needs the right to upload files.
    4354                $font_perm = function () {
    … …  
    142153                        array(
    143154                                'methods'             => 'POST',
    144                                 'permission_callback' => $perm,
     155                                'permission_callback' => $css_perm,
    145156                                'callback'            => array( $this, 'save' ),
    146157                        )
    … …  
    174185                        array(
    175186                                'methods'             => 'POST',
    176                                 'permission_callback' => $perm,
     187                                'permission_callback' => $css_perm,
    177188                                'callback'            => array( $this, 'import_file' ),
    178189                        )
    … …  
    194205                        array(
    195206                                'methods'             => 'POST',
    196                                 'permission_callback' => $perm,
     207                                'permission_callback' => $css_perm,
    197208                                'callback'            => array( Token_Files::class, 'rest_import' ),
    198209                        )
    … …  
    244255                        array(
    245256                                'methods'             => 'POST',
    246                                 'permission_callback' => $perm,
     257                                'permission_callback' => $css_perm,
    247258                                'callback'            => array( $this, 'restore' ),
    248259                        )
    … …  
    869880         * A fingerprint of a token list (same list, same fingerprint).
    870881         *
    871          * @param array $list Normalised tokens.
     882         * @param array $items Normalised tokens.
    872883         * @return string
    873884         */
    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 ) );
    876887        }
    877888
Note: See TracChangeset for help on using the changeset viewer.