| @@ -151,23 +151,8 @@ | ||
| 151 | 151 | |
| 152 | 152 | return $_favourites; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function normalizeReviews( $favourites, $_favourites = [], $undo = false ){ | |
| 156 | - array_map( function( $item ) use ( &$_favourites) { | |
| 157 | - if( ! is_null( $item ) ) { | |
| 158 | - $item = (array) $item; | |
| 159 | - if ( !isset( $_favourites[ $item['type'] ] ) ){ | |
| 160 | - $_favourites[ $item['type'] ] = []; | |
| 161 | - } | |
| 162 | - $_favourites[ $item['type'] ][$item['type_id']] = $item['rating']; | |
| 163 | - } | |
| 164 | - return $_favourites; | |
| 165 | - }, $favourites ); | |
| 166 | - | |
| 167 | - return $_favourites; | |
| 168 | - } | |
| 169 | - | |
| 170 | 155 | /** |
| 171 | 156 | * Trigger Error |
| 172 | 157 | * |
| 173 | 158 | * @param object $triggered_by |
| @@ -187,97 +172,13 @@ | ||
| 187 | 172 | * @param mixed $log |
| 188 | 173 | * @return void |
| 189 | 174 | */ |
| 190 | 175 | public static function log( $log ){ |
| 191 | - if ( defined('WP_DEBUG_LOG') && WP_DEBUG_LOG === true ) { | |
| 176 | + if ( WP_DEBUG_LOG === true ) { | |
| 192 | 177 | if ( is_array( $log ) || is_object( $log ) ) { |
| 193 | 178 | error_log( print_r( $log, true ) ); |
| 194 | 179 | } else { |
| 195 | - error_log( $log ?: '' ); | |
| 180 | + error_log( $log ); | |
| 196 | 181 | } |
| 197 | 182 | } |
| 198 | 183 | } |
| 199 | - | |
| 200 | - public static function should_flush(){ | |
| 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; | |
| 281 | - } | |
| 282 | - | |
| 283 | 184 | } |