Allowlist konstanty
Plugin::AFFILIATE_STATUSES = ['pending', 'active', 'suspended', 'rejected'];
Plugin::COMMISSION_TYPES = ['default', 'percentage', 'fixed'];
Plugin::PAYMENT_METHODS = ['bank', 'paypal', 'check'];
Použijte v custom validaci, REST args enums, nebo UI dropdownech pro zachování konzistence s pluginem.
Version constants
AFFINITE_WP_AFFILIATE_VERSION— verze pluginu (single source of truth v bootstrap souboru).Plugin::VERSION— class const odvozený od bootstrap define.DatabaseInstaller::DB_VERSION— verze DB schématu (může se lišit od plugin verze).
Path/URL constants
AFFINITE_WP_AFFILIATE_DIRECTORY— absolute path k plugin folder (trailing slash).AFFINITE_WP_AFFILIATE_URL— public URL k plugin folder.AFFINITE_WP_AFFILIATE_BASENAME— basename pro is_plugin_active checks.AFFINITE_WP_AFFILIATE_FILE— main plugin file path.
Helper funkce (global namespace)
affinite_format_price(float $price, ?string $currency = null): string
Naformátuje částku podle nakonfigurovaného currency formátu.
echo affinite_format_price(1234.56);
// → "1 234,56 Kč" (pro CZK setup)
affinite_get_currency(): string
Vrátí aktuální currency code (z affiliate plugin settings, ne WC).
$currency = affinite_get_currency();
// → "CZK" / "EUR" / "USD" ...
affinite_get_currency_symbol(?string $currency = null): string
Vrátí symbol pro currency (default aktuální).
echo affinite_get_currency_symbol(); // → "Kč"
echo affinite_get_currency_symbol('EUR'); // → "€"
Static helpers v Plugin
Plugin::get_instance()— singleton accessor.Plugin::get_dashboard_url()— URL configured dashboard page.Plugin::get_login_url()— URL configured login page.Plugin::get_registration_url()— URL configured registration page.
Repository access
$repo = new AffiniteWPAffiliateAffiliateAffiliateRepository();
$affiliate = $repo->get(123);
$by_code = $repo->get_by_code('ABC123');
$by_email = $repo->get_by_email('test@example.com');
$list = $repo->get_list(['status' => 'active', 'limit' => 50]);
$count = $repo->count(['status' => 'active']);
$dropdown = $repo->get_dropdown_options('active');
$map = $repo->get_by_ids([1, 2, 3]); // keyed by ID
