array( 'page', 'post' ), 'roles' => array( 'administrator', 'editor' ), 'content_roles' => array(), 'default_template' => 'akram-full', 'bp_laptop' => true, 'bp_l' => 1366, 'bp_t' => 1024, 'bp_m' => 767, 'css_method' => 'file', 'google_cdn' => false, // opt-in: visitors load fonts from Google's servers 'google_fonts' => true, 'lazy_bg' => true, 'disable_emojis' => true, 'disable_embeds' => false, 'disable_block_css' => true, 'disable_dashicons' => true, 'jquery_migrate' => false, 'preload_fonts' => true, 'svg_uploads' => true, 'captcha' => 'none', 'recaptcha_site' => '', 'recaptcha_secret' => '', 'turnstile_site' => '', 'turnstile_secret' => '', 'mailchimp_key' => '', 'instagram_token' => '', 'google_places_key' => '', 'maintenance' => 'off', 'maintenance_tpl' => 0, 'disabled_widgets' => array(), 'retention_days' => 0, 'form_rate' => 5, 'custom_fonts' => array(), 'remove_data' => false, 'editor_theme' => 'dark', 'prefetch' => 'moderate', 'view_transitions' => true, 'smooth_scroll' => false, 'preloader' => 'none', 'brand_name' => '', 'brand_logo' => '', ); } public static function all() { if ( null === self::$settings ) { $saved = get_option( 'akram_settings', array() ); self::$settings = array_merge( self::default_settings(), is_array( $saved ) ? $saved : array() ); } return self::$settings; } public static function get( $key, $default = null ) { $all = self::all(); return array_key_exists( $key, $all ) ? $all[ $key ] : $default; } public static function update( array $values ) { $defaults = self::default_settings(); $current = self::all(); foreach ( $values as $key => $value ) { if ( ! array_key_exists( $key, $defaults ) ) { continue; } $type = gettype( $defaults[ $key ] ); if ( 'boolean' === $type ) { $value = (bool) $value; } elseif ( 'integer' === $type ) { $value = (int) $value; } elseif ( 'array' === $type ) { $value = is_array( $value ) ? self::clean_array( $value, $key ) : array(); } else { $value = sanitize_text_field( (string) $value ); } $current[ $key ] = $value; } update_option( 'akram_settings', $current ); self::$settings = null; return self::all(); } private static function clean_array( $value, $key ) { if ( 'custom_fonts' === $key ) { $out = array(); foreach ( $value as $font ) { if ( empty( $font['family'] ) ) { continue; } $faces = array(); foreach ( (array) ( $font['faces'] ?? array() ) as $face ) { $faces[] = array( 'weight' => preg_replace( '/[^0-9]/', '', (string) ( $face['weight'] ?? '400' ) ) ?: '400', 'style' => 'italic' === ( $face['style'] ?? '' ) ? 'italic' : 'normal', 'url' => esc_url_raw( $face['url'] ?? '' ), ); } $out[] = array( 'family' => sanitize_text_field( $font['family'] ), 'faces' => $faces, ); } return $out; } return array_values( array_map( 'sanitize_key', array_filter( $value, 'is_scalar' ) ) ); } /** Breakpoints as used by the render engine (desktop-first). */ public static function breakpoints() { $s = self::all(); $bps = array( array( 'id' => 'd', 'label' => 'Desktop', 'icon' => 'monitor', 'width' => 1440, ), ); if ( $s['bp_laptop'] ) { $bps[] = array( 'id' => 'l', 'label' => 'Laptop', 'icon' => 'laptop', 'max' => (int) $s['bp_l'], 'width' => min( 1280, (int) $s['bp_l'] ), ); } $bps[] = array( 'id' => 't', 'label' => 'Tablet', 'icon' => 'tablet', 'max' => (int) $s['bp_t'], 'width' => 820, ); $bps[] = array( 'id' => 'm', 'label' => 'Mobile', 'icon' => 'smartphone', 'max' => (int) $s['bp_m'], 'width' => 390, ); return $bps; } public static function globals() { $g = get_option( 'akram_globals', array() ); return is_array( $g ) ? $g : array(); } public static function enabled_post_types() { $types = (array) self::get( 'post_types', array( 'page' ) ); $types = array_merge( $types, array( 'akram_template' ) ); return array_values( array_unique( array_filter( $types, 'post_type_exists' ) ) ); } public static function has_woo() { return class_exists( 'WooCommerce' ); } }