@@ -153,6 +153,24 @@ public function current_user_can() {
153153 return current_user_can ( $ this ->get_cap () );
154154 }
155155
156+ /**
157+ * Retrieve the name of the capability required to manage sub-site snippets
158+ *
159+ * @return string
160+ */
161+ public function get_cap_name () {
162+ return apply_filters ( 'code_snippets_cap ' , 'manage_snippets ' );
163+ }
164+
165+ /**
166+ * Retrieve the name of the capability required to manage network snippets
167+ *
168+ * @return string
169+ */
170+ public function get_network_cap_name () {
171+ return apply_filters ( 'code_snippets_network_cap ' , 'manage_network_snippets ' );
172+ }
173+
156174 /**
157175 * Get the required capability to perform a certain action on snippets.
158176 * Does not check if the user has this capability or not.
@@ -171,11 +189,11 @@ public function get_cap() {
171189 /* If multisite is enabled and the snippet menu is not activated,
172190 restrict snippet operations to super admins only */
173191 if ( empty ( $ menu_perms ['snippets ' ] ) ) {
174- return apply_filters ( ' code_snippets_network_cap ' , ' manage_network_snippets ' );
192+ return $ this -> get_network_cap_name ( );
175193 }
176194 }
177195
178- return apply_filters ( ' code_snippets_cap ' , ' manage_snippets ' );
196+ return $ this -> get_cap_name ( );
179197 }
180198
181199 /**
@@ -190,7 +208,7 @@ function grant_network_cap( $user_id ) {
190208 $ user = new WP_User ( $ user_id );
191209
192210 /* Add the capability */
193- $ user ->add_cap ( apply_filters ( ' code_snippets_network_cap ' , ' manage_network_snippets ' ) );
211+ $ user ->add_cap ( $ this -> get_network_cap_name ( ) );
194212 }
195213
196214 /**
@@ -205,7 +223,7 @@ function remove_network_cap( $user_id ) {
205223 $ user = new WP_User ( $ user_id );
206224
207225 /* Remove the capability */
208- $ user ->remove_cap ( apply_filters ( ' code_snippets_network_cap ' , ' manage_network_snippets ' ) );
226+ $ user ->remove_cap ( $ this -> get_network_cap_name ( ) );
209227 }
210228
211229 /**
0 commit comments