PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.1.10
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.1.10
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Utils/Helper.php +80 -1 3.0.63.1.10 View file →
@@ -187,9 +187,9 @@
187 187 * @param mixed $log
188 188 * @return void
189 189 */
190 190 public static function log( $log ){
191 - if ( defined('WP_DEBUG_LOG') && WP_DEBUG_LOG === true ) {
191 + if ( defined('WP_DEBUG_LOG') && WP_DEBUG_LOG ) {
192 192 if ( is_array( $log ) || is_object( $log ) ) {
193 193 error_log( print_r( $log, true ) );
194 194 } else {
195 195 error_log( $log ?: '' );
@@ -198,7 +198,86 @@
198 198 }
199 199
200 200 public static function should_flush(){
201 201 return (!defined('TEMPLATELY_IGNORE_FLUSH_ALL') || !TEMPLATELY_IGNORE_FLUSH_ALL) && strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') === false;
202 + }
203 +
204 + public static function get_block_by_name($blocks, $search) {
205 + $queue = $blocks;
206 +
207 + while (!empty($queue)) {
208 + $current_block = array_shift($queue);
209 +
210 + if($search === $current_block['blockName']){
211 + return $current_block;
212 + }
213 +
214 + if (isset($current_block['innerBlocks'])) {
215 + // Add nested blocks to the end of the queue for processing
216 + $queue = array_merge($queue, $current_block['innerBlocks']);
217 + }
218 + }
219 +
220 + return false;
221 + }
222 +
223 + /**
224 + * Only checks if user can install/activate plugins
225 + *
226 + * @param [type] $cap
227 + * @param [type] ...$args
228 + * @return void
229 + */
230 + public static function current_user_can($cap, ...$args) {
231 + $user = wp_get_current_user();
232 +
233 + // Multisite super admin has all caps by definition, Unless specifically denied.
234 + if ( is_multisite() && is_super_admin( $user->ID ) ) {
235 + return true;
236 + }
237 +
238 + $caps = map_meta_cap( $cap, $user->ID, ...$args );
239 +
240 + switch ($cap) {
241 + case 'install_plugins':
242 + case 'upload_plugins':
243 + $caps = ['install_plugins'];
244 + break;
245 + case 'install_themes':
246 + case 'upload_themes':
247 + $caps = ['install_themes'];
248 + break;
249 + case 'activate_plugins':
250 + case 'deactivate_plugins':
251 + case 'activate_plugin':
252 + case 'deactivate_plugin':
253 + $caps = ['activate_plugins'];
254 + break;
255 + default:
256 + break;
257 + }
258 +
259 + // Maintain BC for the argument passed to the "user_has_cap" filter.
260 + $args = array_merge( array( $cap, $user->ID ), $args );
261 +
262 + /**
263 + * See WP_User::has_cap() for description.
264 + */
265 + $capabilities = apply_filters( 'user_has_cap', $user->allcaps, $caps, $args, $user );
266 +
267 + // Everyone is allowed to exist.
268 + $capabilities['exist'] = true;
269 +
270 + // Nobody is allowed to do things they are not allowed to do.
271 + unset( $capabilities['do_not_allow'] );
272 +
273 + // Must have ALL requested caps.
274 + foreach ( (array) $caps as $cap ) {
275 + if ( empty( $capabilities[ $cap ] ) ) {
276 + return false;
277 + }
278 + }
279 +
280 + return true;
202 281 }
203 282
204 283 }