slug = $slug; $this->force_free = $force_free; } /** * Whether this is the premium package context (monorepo / stub). * Named without `__premium_only` so Freemius Free preprocessor will not delete it. */ public function is_premium_build(): bool { return ! $this->force_free; } /** * Freemius may strip a real `is__premium_only()` method from Free ZIPs. * Prefer `plugin_suite_fs_can_use_pro()` at call sites that remain in Free. * * @param array $arguments * @return mixed */ public function __call( string $name, array $arguments ) { // Split token so aggressive FS string scrapers are less likely to drop __call. if ( ( 'is__' . 'premium_only' ) === $name ) { return $this->is_premium_build(); } throw new \BadMethodCallException( esc_html( 'Call to undefined method ' . self::class . '::' . sanitize_key( $name ) ) ); } /** * Fail-closed: false unless Freemius SDK grants access or PLUGIN_SUITE_PRO_DEV is set. */ public function can_use_premium_code(): bool { if ( $this->force_free ) { return false; } if ( defined( 'PLUGIN_SUITE_FREE_PREVIEW' ) && PLUGIN_SUITE_FREE_PREVIEW ) { return false; } if ( defined( 'PLUGIN_SUITE_PRO_DEV' ) && PLUGIN_SUITE_PRO_DEV ) { return true; } return false; } public function is_free_plan(): bool { return ! $this->can_use_premium_code(); } public function get_upgrade_url(): string { return '#'; } public function get_slug(): string { return $this->slug; } } } } namespace { // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- shared by every suite plugin, not owned by one product prefix. if ( ! function_exists( 'plugin_suite_fs' ) ) { /** * Shared Freemius-shaped instance (SDK when configured, else fail-closed stub). * * @return \PluginSuite\Shared\License|object */ function plugin_suite_fs( string $slug ) { if ( class_exists( '\PluginSuite\Shared\FreemiusBridge' ) ) { $fs = \PluginSuite\Shared\FreemiusBridge::get( $slug ); if ( $fs ) { return $fs; } } return \PluginSuite\Shared\License::instance( $slug ); } } if ( ! function_exists( 'plugin_suite_site_supported' ) ) { /** * Single-site only for v1 (ADR-09). */ function plugin_suite_site_supported(): bool { return ! is_multisite(); } } if ( ! function_exists( 'plugin_suite_unsupported_multisite_notice' ) ) { /** * Admin notice when running on unsupported Multisite. */ function plugin_suite_unsupported_multisite_notice(): void { if ( ! current_user_can( 'activate_plugins' ) ) { return; } echo '

'; // Plain string: shared file is copied into each plugin ZIP (no shared text domain on .org). echo esc_html( 'Complementary Plugins v1 does not support WordPress Multisite. Please use a single-site install, or deactivate these plugins on the network.' ); echo '

'; } } }