scheme) && 'https' === $cfo->scheme) { return true; } } if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO']) { return true; } return function_exists('is_ssl') ? is_ssl() : false; } public static function is_block_editor() { $curr_screen = get_current_screen(); if (!empty($curr_screen) && method_exists($curr_screen, 'is_block_editor')) { return $curr_screen->is_block_editor(); } return null; } public static function json_decode($data) { $flag = 0; if (defined('JSON_INVALID_UTF8_IGNORE')) { $flag = JSON_INVALID_UTF8_IGNORE | $flag; } return json_decode($data, true, 512, $flag); } public static function decode_entities($string) { $flag = ENT_QUOTES; if (defined('ENT_HTML401')) { $flag = ENT_HTML401 | $flag; } return html_entity_decode(str_replace(array(''', ''', ''', '"'), '\'', $string), $flag, 'UTF-8'); } public static function decode($jwt) { if (!is_string($jwt) || empty($jwt)) { return null; } $parts = explode('.', $jwt); if (count($parts) !== 3) { return null; } list($header, $payload, $signature) = $parts; $payload = self::base64url_decode($payload); if ($payload === false) { return null; } $data = json_decode($payload, true); return is_array($data) ? $data : null; } private static function base64url_decode($input) { $remainder = strlen($input) % 4; if ($remainder) { $padlen = 4 - $remainder; $input .= str_repeat('=', $padlen); } $input = strtr($input, '-_', '+/'); return base64_decode($input); } public static function inject_localstorage_script($mail, $token, $app_id) { if (is_admin()) { set_transient('alertwise_localstorage_data', [ 'mail' => $mail, 'token' => $token, 'app_id' => $app_id, ], 60); // store for 60 seconds } } public static function get_plugin_info() { $plugin_data = get_plugin_data(ALERTWISE_FILE); return [ 'name' => $plugin_data['Name'], 'version' => $plugin_data['Version'], 'description' => $plugin_data['Description'], 'author' => $plugin_data['Author'], 'plugin_uri' => $plugin_data['PluginURI'], 'license' => $plugin_data['License'] ?? 'GPLv2 or later', ]; } public static function get_push_options_post_meta($post_id) { $push_options = []; $post_meta = get_post_meta($post_id, 'aw_push_options', true); if (!empty($post_meta)) { if (is_string($post_meta)) { $push_options = Helpers::json_decode($post_meta); } else { $push_options = $post_meta; } } return $push_options; } }