register(); ( new Wp\Settings() )->register(); ( new Wp\Assets() )->register(); ( new Wp\Shortcodes() )->register(); ( new Wp\FormHandler() )->register(); ( new Wp\Blocks() )->register(); ( new Wp\Multilingual() )->register(); ( new Wp\Privacy() )->register(); if ( is_admin() ) { ( new Wp\Admin() )->register(); ( new Wp\Wizard() )->register(); } } public static function activate() : void { ( new Wp\Cpt() )->registerPostType(); flush_rewrite_rules(); set_transient( 'admirly_do_activation_redirect', 1, 60 ); } /** @var array> Per-request cache of fields(), keyed by context. */ private static array $fieldsCache = []; /** * Normalized field definitions (roles and sub-field; extensions add their own lists); translated on the front end. * * @return array */ public static function fields() : array { $key = ( is_admin() ? 'admin' : 'front:' . Wp\Multilingual::current() ); if ( !isset( self::$fieldsCache[$key] ) ) { $raw = (array) self::opt( 'fields', [] ); $f = \Admirly\Domain\FieldConfig::normalize( $raw ); /** @param array $f Normalized fields. @param array $raw Raw `fields` setting. */ $f = (array) apply_filters( 'admirly_fields', $f, $raw ); self::$fieldsCache[$key] = ( is_admin() ? $f : Wp\Multilingual::translateFields( $f ) ); } return self::$fieldsCache[$key]; } public static function clearFieldsCache() : void { self::$fieldsCache = []; } /** A sector preset with any extension fields applied. @return array|null */ public static function preset( string $key ) : ?array { /** @param array|null $preset */ return apply_filters( 'admirly_preset', \Admirly\Domain\Presets::get( $key ), $key ); } /** All presets (see preset()). @return array> */ public static function presets() : array { $out = []; foreach ( \Admirly\Domain\Presets::keys() as $k ) { $p = self::preset( $k ); if ( $p !== null ) { $out[$k] = $p; } } return $out; } /** Upgrade / pricing URL (Freemius pricing page when the SDK is loaded). */ public static function upgradeUrl() : string { if ( function_exists( 'admirly_fs' ) && admirly_fs() ) { return (string) admirly_fs()->get_upgrade_url(); } return 'https://admirly.com/wordpress-plugin/'; } /** read a setting (with defaults). */ public static function opt( string $key, $fallback = null ) { $opts = get_option( self::OPTION, [] ); if ( !is_array( $opts ) ) { $opts = []; } $defaults = Wp\Settings::defaults(); return $opts[$key] ?? $defaults[$key] ?? $fallback; } }