requiresWooCommerce && ! Manifest::flag( 'wc' ) ) { $missing[] = __( 'افزونه ووکامرس باید نصب و فعال باشد.', 'rahkar-toolkit' ); return $missing; } if ( $this->requiresWooCommerce && defined( 'WC_VERSION' ) && version_compare( (string) WC_VERSION, $this->minWooCommerce, '<' ) ) { $missing[] = sprintf( /* translators: %s: minimum WooCommerce version */ __( 'به ووکامرس نسخه %s یا بالاتر نیاز دارد.', 'rahkar-toolkit' ), $this->minWooCommerce ); } return $missing; } /** * {@inheritDoc} */ public function defaults(): array { return []; } /** * Read one of this module's settings. * * @param string $key Setting key, without the module prefix. * @param mixed $fallback Value when the key is neither stored nor defaulted. * * @return mixed */ protected function setting( string $key, mixed $fallback = null ): mixed { return Settings::get( $this->slug() . '.' . $key, $fallback ); } /** * Read one of this module's boot switches. * * Use this, not {@see self::setting()}, for anything consulted inside * `register()`. The value comes from the manifest — already in memory, no * query — instead of this module's settings row, which `setting()` would have * to fetch on every request just to decide whether to add a filter. * * The key must be declared in the module's `switches` entry in * {@see \Rahkar\WP\Modules\ModuleManager}'s catalogue, which is also where its * default lives — deliberately not repeated at the call site, so a default can * be changed in one place. * * @param string $key Setting key, without the module prefix. */ protected function bootSwitch( string $key ): bool { return Manifest::bootSwitch( $this->slug() . '.' . $key ); } /** * All of this module's settings. * * @return array */ protected function settings(): array { return Settings::all( $this->slug() ); } }