| @@ -116,18 +116,28 @@ | ||
| 116 | 116 | /** |
| 117 | 117 | * get_permission_callback_method |
| 118 | 118 | * |
| 119 | 119 | * Returns a reference to the permission callback for the method if exists or the default one if it doesn't. |
| 120 | + * Looks up inherited methods so module Route_Base manage_options gates are honoured. | |
| 121 | + * | |
| 120 | 122 | * @param string $method The REST method name |
| 121 | 123 | * |
| 122 | - * @return callable If a method called (rest-method)_permission_callback exists, returns a reference to it, otherwise | |
| 123 | - * returns a reference to the default member method /permission_callback/. | |
| 124 | + * @return callable If a method called (rest-method)_permission_callback exists, returns a reference to it, | |
| 125 | + * otherwise get_permission_callback when present, otherwise permission_callback. | |
| 124 | 126 | */ |
| 125 | 127 | public function get_permission_callback_method( string $method ): callable { |
| 126 | 128 | $method_name = strtolower( $method ); |
| 127 | 129 | $permission_callback_method = $method_name . '_permission_callback'; |
| 128 | - $permission_callback = $this->method_exists_in_current_class( $permission_callback_method ) ? $permission_callback_method : 'permission_callback'; | |
| 129 | - return [ $this, $permission_callback ]; | |
| 130 | + | |
| 131 | + if ( method_exists( $this, $permission_callback_method ) ) { | |
| 132 | + return [ $this, $permission_callback_method ]; | |
| 133 | + } | |
| 134 | + | |
| 135 | + if ( method_exists( $this, 'get_permission_callback' ) ) { | |
| 136 | + return [ $this, 'get_permission_callback' ]; | |
| 137 | + } | |
| 138 | + | |
| 139 | + return [ $this, 'permission_callback' ]; | |
| 130 | 140 | } |
| 131 | 141 | |
| 132 | 142 | /** |
| 133 | 143 | * maybe_add_args_to_config |