/*
 Theme Name:   Bricks Child Theme
 Theme URI:    https://bricksbuilder.io/
 Description:  Use this child theme to extend Bricks.
 Author:       Bricks
 Author URI:   https://bricksbuilder.io/
 Template:     bricks
 Version:      1.1
 Text Domain:  bricks
*/


/**
 * Bricks License Bypass
 * Add to: wp-content/mu-plugins/bricks-bypass.php
 */

add_action('muplugins_loaded', function() {
    // Block all license API calls to force 'error_remote' status
    add_filter('pre_http_request', function($preempt, $args, $url) {
        if (strpos($url, 'bricksbuilder.io') !== false) {
            return new WP_Error('http_request_failed', 'Connection failed');
        }
        return $preempt;
    }, PHP_INT_MAX, 3);
    
    // Set a license key and valid status
    if (!get_option('bricks_license_key')) {
        update_option('bricks_license_key', 'bypass-' . md5(site_url()));
    }
    
    // Force valid license status (bypasses timeout validation)
    $status = get_transient('bricks_license_status');
    if (!$status || $status === 'invalid') {
        set_transient('bricks_license_status', 'error_remote', 160 * HOUR_IN_SECONDS);
    }
    
    // Prevent manual re-validation
    remove_action('wp_ajax_bricks_revalidate_license', ['Bricks\License', 'revalidate_license']);
}, 1);