0 ) { $user = get_user_by( 'id', $user_id ); if ( in_array( 'administrator', $user->roles, true ) ) { return true; } } return false; } /** * Check if a module is activated * * @param string $module_name Module name. * @return boolean */ private function is_module_activated( string $module_name ) { $modules = get_option( MODULES_OPTION, [] ); if ( ! empty( $module_name ) && ! empty( $modules ) ) { return array_key_exists( sanitize_text_field( $module_name ), $modules ); } return false; } /** * Logging function * * @param string $message Message log. * * @return void */ protected function log( $message ) { // Let's write to the log file. $log_path = ADMINOPTIMIZER_PATH . '/log.txt'; $message = sanitize_textarea_field( $message ); // Timestamp. $text = '[' . date( 'm/d/Y g:i A' ) . '] - ' . $message . "\n"; //phpcs:ignore // Write to log. file_put_contents( $log_path, $text, FILE_APPEND ); //phpcs:ignore } /** * A quick check to see if the current request is REST request * * @return bool */ private function is_rest_request(): bool { if ( ! defined( 'REST_REQUEST' ) || ( defined( 'REST_REQUEST' ) && ! REST_REQUEST ) ) { return false; } else { return true; } } }