Skip to:
Content

bbPress.org

Changeset 6949


Ignore:
Timestamp:
11/14/2019 06:24:11 PM (2 years ago)
Author:
johnjamesjacoby
Message:

Meta Registration: add auth_callback to count meta arguments.

This commit fixes a conflict with plugins that use the WordPress REST API in add/edit page/post screens.

Item count meta keys start with underscores so they would be hidden from view in the Custom Fields meta-box, but that also means they are flagged as protected in the REST API, and without an explicit auth_callback argument __return_false is assumed to be on the safe side.

This change explicitly allows all item count meta keys to be updated or deleted by all users, while still retaining their invisibility as protected meta data.

It also adds more verbose inline documentation to each argument, for improved clarity and future reference.

Fixes #3280. Props pdvwp, rtsbeacon, jufdaniellevideos for their helpful feedback in the forums. For 2.6.1, branches/2.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/bbpress.php

    r6943 r6949  
    752752        // Define "count" meta-type array
    753753        $count = array(
     754
     755            // Counts are always integers
    754756            'type'              => 'integer',
     757
     758            // Generic count description
    755759            'description'       => esc_html__( 'bbPress Item Count', 'bbpress' ),
     760
     761            // Counts are single values
    756762            'single'            => true,
     763
     764            // Counts should be made available in REST
     765            'show_in_rest'      => true,
     766
     767            // Never allow counts to go negative
    757768            'sanitize_callback' => 'bbp_number_not_negative',
    758             'show_in_rest'      => true
     769
     770             // All users may update count meta data
     771            'auth_callback'     => '__return_true'
    759772        );
    760773
Note: See TracChangeset for help on using the changeset viewer.