PluginProbe
SureCookie – GDPR Cookie Consent Banner, Cookie Scanner & Script Blocking / trunk
SureCookie – GDPR Cookie Consent Banner, Cookie Scanner & Script Blocking vtrunk
1.5.0 1.4.0 1.3.0 1.3.1 trunk 0.0.0-alpha.1 0.0.0-alpha.2 0.0.0-alpha.3 0.0.1-beta.1 0.0.1-beta.2 0.0.1-beta.3 0.0.1-beta.4 1.0.0 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4
surecookie / inc / modules / site-scanner / utils.php

utils.php in SureCookie – GDPR Cookie Consent Banner, Cookie Scanner & Script Blocking trunk, at inc/modules/site-scanner/utils.php

69 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Utils Site Scanner.
4 *
5 * @package SureCookie\Inc\Modules\SiteScanner
6 * @since 0.0.1
7 */
8
9 namespace SureCookie\Inc\Modules\SiteScanner;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Utils
17 *
18 * @since 0.0.1
19 */
20 class Utils {
21 /**
22 * Get Site URL for Verification
23 *
24 * Gets the site URL to use for verification
25 *
26 * @since 0.0.1
27 * @return string
28 */
29 public static function get_site_url(): string {
30 return str_replace( 'http://', 'https://', rtrim( get_site_url(), '/' ) ) . '/';
31 }
32
33 /**
34 * Generate a unique site ID based on site URL.
35 *
36 * @since 0.0.1
37 * @return string
38 */
39 public static function generate_site_id(): string {
40 return substr( hash( 'sha256', self::get_site_url() ), 0, 32 );
41 }
42
43 /**
44 * Get the current plan type for further processing.
45 *
46 * @since 0.0.1
47 * @return string Plan type
48 */
49 public static function get_plan(): string {
50 $filtered = apply_filters( 'surecookie_plan_type', 'free' );
51 return is_string( $filtered ) ? $filtered : 'free';
52 }
53
54 /**
55 * Max pages per scan: SaaS quota cache (transient → option) → `surecookie_max_scan_pages` filter (default 5).
56 *
57 * @since 0.0.1-beta.2
58 * @return int
59 */
60 public static function get_max_scan_pages(): int {
61 $cached = SaasClient::get_instance()->get_cached_quota();
62 if ( ! empty( $cached['pages_per_scan_limit'] ) ) {
63 return (int) $cached['pages_per_scan_limit'];
64 }
65
66 return (int) apply_filters( 'surecookie_max_scan_pages', 5 );
67 }
68 }
69