array( 'name' => __( 'Free', 'zonepilot' ), 'price' => '0', 'sites' => 1, ), 'pro' => array( 'name' => __( 'Pro', 'zonepilot' ), 'price' => '79', 'sites' => 1, ), 'business' => array( 'name' => __( 'Pro, 5 sites', 'zonepilot' ), 'price' => '149', 'sites' => 5, ), 'agency' => array( 'name' => __( 'Pro, 25 sites', 'zonepilot' ), 'price' => '299', 'sites' => 25, ), ); } /** * Freemius instance, if the SDK is loaded. * * @return \Freemius|null */ private static function fs() { return function_exists( 'fehu_ap_fs' ) ? fehu_ap_fs() : null; } /** * Active Freemius license on this site, if any. * * @return object|null */ private static function license() { $fs = self::fs(); if ( ! $fs || ! $fs->is_registered() ) { return null; } $license = $fs->_get_license(); return is_object( $license ) ? $license : null; } /** * Pro features unlocked? * * @return bool */ public static function is_pro() { if ( defined( 'FEHU_AP_PRO_DEV' ) && FEHU_AP_PRO_DEV ) { return (bool) apply_filters( 'fehu_ap_is_pro', true ); } $fs = self::fs(); return (bool) apply_filters( 'fehu_ap_is_pro', $fs && $fs->can_use_premium_code() ); } /** * Sites allowed by the active license (0 = unlimited). * * @return int */ public static function sites() { $license = self::license(); if ( $license ) { return isset( $license->quota ) ? (int) $license->quota : 0; } return 1; } /** * Current tier id (free, pro, business, agency), from the number of sites of the license. * * @return string */ public static function plan() { if ( ! self::is_pro() ) { return 'free'; } $sites = self::sites(); if ( 0 === $sites || $sites >= 25 ) { return 'agency'; } return $sites >= 5 ? 'business' : 'pro'; } /** * License data for the admin screen (no keys). * * @return array */ public static function data() { $license = self::license(); return array( 'provider' => 'freemius', 'status' => $license ? ( $license->is_expired() ? 'expired' : 'valid' ) : 'inactive', 'expires' => $license && ! empty( $license->expiration ) ? (int) strtotime( $license->expiration ) : 0, 'sites' => self::sites(), ); } /** * Where to buy or upgrade (Freemius pricing page inside WordPress). * * @return string */ public static function upgrade_url() { $fs = self::fs(); return $fs ? $fs->get_upgrade_url() : self::PLANS_URL; } /** * Where to enter or manage a license key: the Freemius account page, or the activation screen * when the owner skipped the opt-in. * * @return string */ public static function account_url() { $fs = self::fs(); if ( ! $fs ) { return self::PLANS_URL; } if ( $fs->is_registered() ) { return $fs->get_account_url(); } return $fs->is_anonymous() ? $fs->get_reconnect_url() : $fs->get_activation_url(); } }