PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | classes/rest/route.php +14 -4 1.7.6 → trunk View file →
@@ -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