advanced ) && is_object( $config->advanced ) ) { $config->advanced->customCss = ''; } if ( isset( $config->scripts ) ) { $kept = array(); if ( is_array( $config->scripts ) ) { foreach ( $config->scripts as $script ) { if ( is_object( $script ) && isset( $script->type, $script->value ) && 'src' === $script->type && is_string( $script->value ) && consentful_allowed_script_url( $script->value ) ) { $kept[] = $script; } } } $config->scripts = $kept; } return $config; } // Build mode written by the admin build (vite.config.ts): true only for the // WordPress.org review build. if ( file_exists( CONSENTFUL_DIR . 'includes/build-mode.php' ) ) { require_once CONSENTFUL_DIR . 'includes/build-mode.php'; } if ( ! defined( 'CONSENTFUL_RESTRICTED' ) ) { define( 'CONSENTFUL_RESTRICTED', false ); } require_once CONSENTFUL_DIR . 'includes/class-consentful-head.php'; require_once CONSENTFUL_DIR . 'includes/class-consentful-rest.php'; require_once CONSENTFUL_DIR . 'includes/class-consentful-admin.php'; /** * Move a 0.1.x banner over to the JSON option: pull the settings object out of * the stored HTML block, keep it only if it is valid JSON, and drop the block. */ function consentful_migrate_legacy_head() { $legacy = get_option( CONSENTFUL_HEAD_OPTION, null ); if ( null === $legacy ) { return; } if ( is_string( $legacy ) && ! get_option( CONSENTFUL_PUBLISHED_OPTION ) ) { if ( preg_match( '/window\.__CC_CONFIG__=(\{.*?\});<\/script>/s', $legacy, $match ) ) { $decoded = json_decode( $match[1] ); if ( is_object( $decoded ) ) { update_option( CONSENTFUL_PUBLISHED_OPTION, wp_json_encode( $decoded ), true ); } } } delete_option( CONSENTFUL_HEAD_OPTION ); } /** * Boot the three collaborators. Kept dead simple — each registers its own hooks. */ function consentful_boot() { consentful_migrate_legacy_head(); ( new Consentful_Head() )->register(); ( new Consentful_Rest() )->register(); if ( is_admin() ) { ( new Consentful_Admin() )->register(); } } add_action( 'plugins_loaded', 'consentful_boot' ); /** * On uninstall the options are removed (see uninstall.php). On deactivation we * keep them so re-activating restores the banner; a full removal is the explicit * uninstall path. */