Freemius_Abstract

- Each instance of Freemius class represents a single plugin install by a single user (the installer of the plugin).

Defined (1)

The class is defined in the following location(s).

/freemius/includes/class-freemius-abstract.php  
  1. abstract class Freemius_Abstract { 
  2.  
  3. #---------------------------------------------------------------------------------- 
  4. #region Identity 
  5. #---------------------------------------------------------------------------------- 
  6.  
  7. /** 
  8. * Check if user registered with Freemius by connecting his account. 
  9. * @since 1.0.1 
  10. * @return bool 
  11. */ 
  12. abstract function is_registered(); 
  13.  
  14. /** 
  15. * Check if the user skipped connecting the account with Freemius. 
  16. * @since 1.0.7 
  17. * @return bool 
  18. */ 
  19. abstract function is_anonymous(); 
  20.  
  21. /** 
  22. * Check if the user currently in activation mode. 
  23. * @since 1.0.7 
  24. * @return bool 
  25. */ 
  26. abstract function is_activation_mode(); 
  27.  
  28. #endregion 
  29.  
  30. #---------------------------------------------------------------------------------- 
  31. #region Usage Tracking 
  32. #---------------------------------------------------------------------------------- 
  33.  
  34. /** 
  35. * Returns TRUE if the user opted-in and didn't disconnect (opt-out). 
  36. * @author Leo Fajardo (@leorw) 
  37. * @since 1.2.1.5 
  38. * @return bool 
  39. */ 
  40. abstract function is_tracking_allowed(); 
  41.  
  42. /** 
  43. * Returns TRUE if the user never opted-in or manually opted-out. 
  44. * @author Vova Feldman (@svovaf) 
  45. * @since 1.2.1.5 
  46. * @return bool 
  47. */ 
  48. function is_tracking_prohibited() { 
  49. return ! $this->is_registered() || ! $this->is_tracking_allowed(); 
  50.  
  51. /** 
  52. * Opt-out from usage tracking. 
  53. * Note: This will not delete the account information but will stop all tracking. 
  54. * Returns: 
  55. * 1. FALSE - If the user never opted-in. 
  56. * 2. TRUE - If successfully opted-out. 
  57. * 3. object - API Result on failure. 
  58. * @author Leo Fajardo (@leorw) 
  59. * @since 1.2.1.5 
  60. * @return bool|object 
  61. */ 
  62. abstract function stop_tracking(); 
  63.  
  64. /** 
  65. * Opt-in back into usage tracking. 
  66. * Note: This will only work if the user opted-in previously. 
  67. * Returns: 
  68. * 1. FALSE - If the user never opted-in. 
  69. * 2. TRUE - If successfully opted-in back to usage tracking. 
  70. * 3. object - API result on failure. 
  71. * @author Leo Fajardo (@leorw) 
  72. * @since 1.2.1.5 
  73. * @return bool|object 
  74. */ 
  75. abstract function allow_tracking(); 
  76.  
  77. #endregion 
  78.  
  79. #---------------------------------------------------------------------------------- 
  80. #region Permissions 
  81. #---------------------------------------------------------------------------------- 
  82.  
  83. /** 
  84. * Check if plugin must be WordPress.org compliant. 
  85. * @since 1.0.7 
  86. * @return bool 
  87. */ 
  88. abstract function is_org_repo_compliant(); 
  89.  
  90. /** 
  91. * Check if plugin is allowed to install executable files. 
  92. * @author Vova Feldman (@svovaf) 
  93. * @since 1.0.5 
  94. * @return bool 
  95. */ 
  96. function is_allowed_to_install() { 
  97. return ( $this->is_premium() || ! $this->is_org_repo_compliant() ); 
  98.  
  99. #endregion 
  100.  
  101. /** 
  102. * Check if user in trial or in free plan (not paying). 
  103. * @author Vova Feldman (@svovaf) 
  104. * @since 1.0.4 
  105. * @return bool 
  106. */ 
  107. function is_not_paying() { 
  108. return ( $this->is_trial() || $this->is_free_plan() ); 
  109.  
  110. /** 
  111. * Check if the user has an activated and valid paid license on current plugin's install. 
  112. * @since 1.0.9 
  113. * @return bool 
  114. */ 
  115. abstract function is_paying(); 
  116.  
  117. /** 
  118. * Check if the user is paying or in trial. 
  119. * @since 1.0.9 
  120. * @return bool 
  121. */ 
  122. function is_paying_or_trial() { 
  123. return ( $this->is_paying() || $this->is_trial() ); 
  124.  
  125. /** 
  126. * Check if user in a trial or have feature enabled license. 
  127. * @author Vova Feldman (@svovaf) 
  128. * @since 1.1.7 
  129. * @return bool 
  130. */ 
  131. abstract function can_use_premium_code(); 
  132.  
  133. #---------------------------------------------------------------------------------- 
  134. #region Premium Only 
  135. #---------------------------------------------------------------------------------- 
  136.  
  137. /** 
  138. * All logic wrapped in methods with "__premium_only()" suffix will be only 
  139. * included in the premium code. 
  140. * Example: 
  141. * if ( freemius()->is__premium_only() ) { 
  142. * ... 
  143. * } 
  144. */ 
  145.  
  146. /** 
  147. * Returns true when running premium plugin code. 
  148. * @since 1.0.9 
  149. * @return bool 
  150. */ 
  151. function is__premium_only() { 
  152. return $this->is_premium(); 
  153.  
  154. /** 
  155. * Check if the user has an activated and valid paid license on current plugin's install. 
  156. * @since 1.0.9 
  157. * @return bool 
  158. */ 
  159. function is_paying__premium_only() { 
  160. return ( $this->is__premium_only() && $this->is_paying() ); 
  161.  
  162. /** 
  163. * All code wrapped in this statement will be only included in the premium code. 
  164. * @since 1.0.9 
  165. * @param string $plan Plan name 
  166. * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. 
  167. * @return bool 
  168. */ 
  169. function is_plan__premium_only( $plan, $exact = false ) { 
  170. return ( $this->is_premium() && $this->is_plan( $plan, $exact ) ); 
  171.  
  172. /** 
  173. * Check if plan matches active license' plan or active trial license' plan. 
  174. * All code wrapped in this statement will be only included in the premium code. 
  175. * @since 1.0.9 
  176. * @param string $plan Plan name 
  177. * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. 
  178. * @return bool 
  179. */ 
  180. function is_plan_or_trial__premium_only( $plan, $exact = false ) { 
  181. return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) ); 
  182.  
  183. /** 
  184. * Check if the user is paying or in trial. 
  185. * All code wrapped in this statement will be only included in the premium code. 
  186. * @since 1.0.9 
  187. * @return bool 
  188. */ 
  189. function is_paying_or_trial__premium_only() { 
  190. return $this->is_premium() && $this->is_paying_or_trial(); 
  191.  
  192. /** 
  193. * Check if the user has an activated and valid paid license on current plugin's install. 
  194. * @since 1.0.4 
  195. * @return bool 
  196. * @deprecated Method name is confusing since it's not clear from the name the code will be removed. 
  197. * @using Alias to is_paying__premium_only() 
  198. */ 
  199. function is_paying__fs__() { 
  200. return $this->is_paying__premium_only(); 
  201.  
  202. /** 
  203. * Check if user in a trial or have feature enabled license. 
  204. * All code wrapped in this statement will be only included in the premium code. 
  205. * @author Vova Feldman (@svovaf) 
  206. * @since 1.1.9 
  207. * @return bool 
  208. */ 
  209. function can_use_premium_code__premium_only() { 
  210. return $this->is_premium() && $this->can_use_premium_code(); 
  211.  
  212. #endregion 
  213.  
  214. #---------------------------------------------------------------------------------- 
  215. #region Trial 
  216. #---------------------------------------------------------------------------------- 
  217.  
  218. /** 
  219. * Check if the user in a trial. 
  220. * @since 1.0.3 
  221. * @return bool 
  222. */ 
  223. abstract function is_trial(); 
  224.  
  225. /** 
  226. * Check if trial already utilized. 
  227. * @since 1.0.9 
  228. * @return bool 
  229. */ 
  230. abstract function is_trial_utilized(); 
  231.  
  232. #endregion 
  233.  
  234. #---------------------------------------------------------------------------------- 
  235. #region Plans 
  236. #---------------------------------------------------------------------------------- 
  237.  
  238. /** 
  239. * Check if plugin using the free plan. 
  240. * @since 1.0.4 
  241. * @return bool 
  242. */ 
  243. abstract function is_free_plan(); 
  244.  
  245. /** 
  246. * @since 1.0.2 
  247. * @param string $plan Plan name 
  248. * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. 
  249. * @return bool 
  250. */ 
  251. abstract function is_plan( $plan, $exact = false ); 
  252.  
  253. /** 
  254. * Check if plan based on trial. If not in trial mode, should return false. 
  255. * @since 1.0.9 
  256. * @param string $plan Plan name 
  257. * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. 
  258. * @return bool 
  259. */ 
  260. abstract function is_trial_plan( $plan, $exact = false ); 
  261.  
  262. /** 
  263. * Check if plan matches active license' plan or active trial license' plan. 
  264. * @since 1.0.9 
  265. * @param string $plan Plan name 
  266. * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans. 
  267. * @return bool 
  268. */ 
  269. function is_plan_or_trial( $plan, $exact = false ) { 
  270. return $this->is_plan( $plan, $exact ) || 
  271. $this->is_trial_plan( $plan, $exact ); 
  272.  
  273. /** 
  274. * Check if plugin has any paid plans. 
  275. * @author Vova Feldman (@svovaf) 
  276. * @since 1.0.7 
  277. * @return bool 
  278. */ 
  279. abstract function has_paid_plan(); 
  280.  
  281. /** 
  282. * Check if plugin has any free plan, or is it premium only. 
  283. * Note: If no plans configured, assume plugin is free. 
  284. * @author Vova Feldman (@svovaf) 
  285. * @since 1.0.7 
  286. * @return bool 
  287. */ 
  288. abstract function has_free_plan(); 
  289.  
  290. /** 
  291. * Check if plugin is premium only (no free plans). 
  292. * NOTE: is__premium_only() is very different method, don't get confused. 
  293. * @author Vova Feldman (@svovaf) 
  294. * @since 1.1.9 
  295. * @return bool 
  296. */ 
  297. abstract function is_only_premium(); 
  298.  
  299. /** 
  300. * Checks if it's a freemium plugin. 
  301. * @author Vova Feldman (@svovaf) 
  302. * @since 1.1.9 
  303. * @return bool 
  304. */ 
  305. function is_freemium() { 
  306. return $this->has_paid_plan() && 
  307. $this->has_free_plan(); 
  308.  
  309. #endregion 
  310.  
  311. /** 
  312. * Check if running payments in sandbox mode. 
  313. * @since 1.0.4 
  314. * @return bool 
  315. */ 
  316. abstract function is_payments_sandbox(); 
  317.  
  318. /** 
  319. * Check if running test vs. live plugin. 
  320. * @since 1.0.5 
  321. * @return bool 
  322. */ 
  323. abstract function is_live(); 
  324.  
  325. /** 
  326. * Check if running premium plugin code. 
  327. * @since 1.0.5 
  328. * @return bool 
  329. */ 
  330. abstract function is_premium(); 
  331.  
  332. /** 
  333. * Get upgrade URL. 
  334. * @author Vova Feldman (@svovaf) 
  335. * @since 1.0.2 
  336. * @param string $period Billing cycle 
  337. * @return string 
  338. */ 
  339. abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY ); 
  340.  
  341. /** 
  342. * Check if Freemius was first added in a plugin update. 
  343. * @author Vova Feldman (@svovaf) 
  344. * @since 1.1.5 
  345. * @return bool 
  346. */ 
  347. function is_plugin_update() { 
  348. return ! $this->is_plugin_new_install(); 
  349.  
  350. /** 
  351. * Check if Freemius was part of the plugin when the user installed it first. 
  352. * @author Vova Feldman (@svovaf) 
  353. * @since 1.1.5 
  354. * @return bool 
  355. */ 
  356. abstract function is_plugin_new_install(); 
  357.  
  358. #---------------------------------------------------------------------------------- 
  359. #region Marketing 
  360. #---------------------------------------------------------------------------------- 
  361.  
  362. /** 
  363. * Check if current user purchased any other plugins before. 
  364. * @author Vova Feldman (@svovaf) 
  365. * @since 1.0.9 
  366. * @return bool 
  367. */ 
  368. abstract function has_purchased_before(); 
  369.  
  370. /** 
  371. * Check if current user classified as an agency. 
  372. * @author Vova Feldman (@svovaf) 
  373. * @since 1.0.9 
  374. * @return bool 
  375. */ 
  376. abstract function is_agency(); 
  377.  
  378. /** 
  379. * Check if current user classified as a developer. 
  380. * @author Vova Feldman (@svovaf) 
  381. * @since 1.0.9 
  382. * @return bool 
  383. */ 
  384. abstract function is_developer(); 
  385.  
  386. /** 
  387. * Check if current user classified as a business. 
  388. * @author Vova Feldman (@svovaf) 
  389. * @since 1.0.9 
  390. * @return bool 
  391. */ 
  392. abstract function is_business(); 
  393.  
  394. #endregion