Skip to content
This repository was archived by the owner on Mar 14, 2021. It is now read-only.

Commit 26b8295

Browse files
authored
Merge pull request #31 from Codeinwp/development
Added freemius support
2 parents fe35d2c + ed01949 commit 26b8295

File tree

119 files changed

+30873
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+30873
-7
lines changed

README.txt

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ If you don't have any caching/minify plugin, it is mostly due to your theme whic
128128

129129
== Changelog ==
130130

131+
= 2.0.8 =
132+
* Added freemius support
133+
* Fixed notification issues
134+
131135
= 2.0.6 =
132136
* Fixed modal position issues.
133137
* Fixed cookies upgrade routines

adblock-notify.php

+34-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Plugin Name: Adblock Notify Lite
88
* Plugin URI: http://themeisle.com/plugins/adblock-notify-lite/
99
* Description: An Adblock detection and nofitication plugin with get around options and a lot of settings. Dashboard widget with adblock counter included!
10-
* Version: 2.0.7
10+
* Version: 2.0.8
1111
* Author: Themeisle
1212
* Author URI: http://themeisle.com
1313
* Text Domain: an-translate
@@ -47,7 +47,7 @@
4747
define( 'AN_COOKIE', 'anCookie' );
4848
}
4949
if ( ! defined( 'AN_VERSION' ) ) {
50-
define( 'AN_VERSION', '2.0.7' );
50+
define( 'AN_VERSION', '2.0.8' );
5151
}
5252
if ( ! defined( 'AN_TEMP_DEVELOPMENT' ) ) {
5353
define( 'AN_TEMP_DEVELOPMENT', false );
@@ -399,3 +399,35 @@ function adblocker_notify_uninstall() {
399399
an_delete_option( 'adblocker_notify_counter' );
400400
an_delete_option( 'adblocker_notify_selectors' );
401401
}
402+
403+
/**
404+
* Added Freemius support
405+
*
406+
* @return Freemius
407+
*/
408+
function anbb_fs() {
409+
global $anbb_fs;
410+
411+
if ( ! isset( $anbb_fs ) ) {
412+
// Include Freemius SDK.
413+
require_once AN_PATH . 'vendor/freemius/start.php';
414+
415+
$anbb_fs = fs_dynamic_init( array(
416+
'id' => '503',
417+
'slug' => 'adblock-notify-by-bweb',
418+
'type' => 'plugin',
419+
'public_key' => 'pk_80661c61db7cdcbedd0f6461d6a1b',
420+
'is_premium' => false,
421+
'has_addons' => false,
422+
'has_paid_plans' => false,
423+
'menu' => array(
424+
'slug' => 'adblock-notify',
425+
),
426+
) );
427+
}
428+
429+
return $anbb_fs;
430+
}
431+
432+
// Init Freemius.
433+
anbb_fs();

css/an-style.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
an_style.css
33
AdBlock Notify
44
Copyright: (c) 2016 Themeisle, themeisle.com
5-
Version: 2.0.7
5+
Version: 2.0.8
66
*/
77
.reveal-modal-bg {
88
display: none;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adblock-notify-by-bweb",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"description": "Adblock Notify plugin",
55
"repository": {
66
"type": "git",

vendor/freemius/.codeclimate.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
engines:
2+
phpcodesniffer:
3+
enabled: true
4+
config:
5+
standard: "WordPress"
6+
checks:
7+
Squiz Commenting InlineComment InvalidEndChar:
8+
enabled: false
9+
Squiz Commenting InlineComment SpacingBefore:
10+
enabled: false
11+
ratings:
12+
paths:
13+
- "**.php"

vendor/freemius/.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sudo: false
2+
3+
language: php
4+
5+
php:
6+
- 5.3
7+
- 5.4
8+
- 5.5
9+
- 5.6
10+
- 7.0
11+
- hhvm

vendor/freemius/LICENSE.txt

+340
Large diffs are not rendered by default.

vendor/freemius/README.md

+250
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
Freemius WordPress SDK
2+
======================
3+
4+
Freemius is an [analytics](https://freemius.com/wordpress/insights/) & [monetization](https://freemius.com/wordpress/) platform for plugin developers. Freemius empower developers with advanced real-time analytics and helps turning any plugin into a commercial product in less than 10 min.
5+
6+
The platform is fully functional and running in production. Having said that, the monetization platform is still in closed beta.
7+
If you are a WordPress plugin developer and you are interested to monetize with Freemius [apply to our closed beta here](http://bit.ly/freemius-beta):
8+
9+
http://bit.ly/freemius-beta
10+
11+
**Below you'll find the integration instructions for our WordPress SDK.**
12+
13+
## Code Documentation
14+
15+
You can find the SDK's PHP-Doc documentation here:
16+
https://codedoc.pub/freemius/wordpress-sdk/master/
17+
18+
## Initializing the SDK
19+
20+
Copy the code below and paste it into the top of your main plugin's PHP file, right after the plugin's header comment:
21+
22+
```php
23+
<?php
24+
// Create a helper function for easy SDK access.
25+
function my_prefix_fs() {
26+
global $my_prefix_fs;
27+
if ( ! isset( $my_prefix_fs ) ) {
28+
// Include Freemius SDK.
29+
require_once dirname(__FILE__) . '/freemius/start.php';
30+
31+
$my_prefix_fs = fs_dynamic_init( array(
32+
'id' => '1234',
33+
'slug' => 'my-plugin-slug',
34+
'menu_slug' => 'my_menu_slug', // You can also use __FILE__
35+
'public_key' => 'pk_MY_PUBLIC_KEY',
36+
'is_live' => true,
37+
'is_premium' => true,
38+
'has_addons' => false,
39+
'has_paid_plans' => false,
40+
// Set the SDK to work in a sandbox mode (for development & testing).
41+
// IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
42+
'secret_key' => 'sk_MY_SECRET_KEY',
43+
) );
44+
}
45+
46+
return $my_prefix_fs;
47+
}
48+
49+
// Init Freemius.
50+
my_prefix_fs();
51+
?>
52+
```
53+
54+
- **1234** - Replace with your plugin's ID.
55+
- **pk_MY_PUBLIC_KEY** - Replace with your plugin's public key.
56+
- **sk_MY_SECRET_KEY** - Replace with your plugin's secret key.
57+
- **my-plugin-slug** - Replace with your plugin's WordPress.org slug.
58+
- **my_menu_slug** - Replace with your admin dashboard settings menu slug.
59+
60+
61+
## Usage example
62+
63+
You can call the SDK by using the shortcode function:
64+
65+
```php
66+
<?php my_prefix_fs()->get_upgrade_url(); ?>
67+
```
68+
69+
Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
70+
71+
```php
72+
<?php
73+
global $my_prefix_fs;
74+
$my_prefix_fs->get_account_url();
75+
?>
76+
```
77+
78+
## Adding license based logic examples
79+
80+
Add marketing content to encourage your users to upgrade for your paid version:
81+
82+
```php
83+
<?php
84+
if ( my_prefix_fs()->is_not_paying() ) {
85+
echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
86+
echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
87+
esc_html__('Upgrade Now!', 'my-plugin-slug') .
88+
'</a>';
89+
echo '</section>';
90+
}
91+
?>
92+
```
93+
94+
Add logic which will only be available in your premium plugin version:
95+
96+
```php
97+
<?php
98+
// This "if" block will be auto removed from the Free version.
99+
if ( my_prefix_fs()->is__premium_only() ) {
100+
101+
// ... premium only logic ...
102+
103+
}
104+
?>
105+
```
106+
107+
To add a function which will only be available in your premium plugin version, simply add __premium_only as the suffix of the function name. Just make sure that all lines that call that method directly or by hooks, are also wrapped in premium only logic:
108+
109+
```php
110+
<?php
111+
class My_Plugin {
112+
function init() {
113+
...
114+
115+
// This "if" block will be auto removed from the free version.
116+
if ( my_prefix_fs()->is__premium_only() ) {
117+
// Init premium version.
118+
$this->admin_init__premium_only();
119+
120+
add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
121+
}
122+
123+
...
124+
}
125+
126+
// This method will be only included in the premium version.
127+
function admin_init__premium_only() {
128+
...
129+
}
130+
131+
// This method will be only included in the premium version.
132+
function admin_init_hook__premium_only() {
133+
...
134+
}
135+
}
136+
?>
137+
```
138+
139+
Add logic which will only be executed for customers in your 'professional' plan:
140+
141+
```php
142+
<?php
143+
if ( my_prefix_fs()->is_plan('professional', true) ) {
144+
// .. logic related to Professional plan only ...
145+
}
146+
?>
147+
```
148+
149+
Add logic which will only be executed for customers in your 'professional' plan or higher plans:
150+
151+
```php
152+
<?php
153+
if ( my_prefix_fs()->is_plan('professional') ) {
154+
// ... logic related to Professional plan and higher plans ...
155+
}
156+
?>
157+
```
158+
159+
Add logic which will only be available in your premium plugin version AND will only be executed for customers in your 'professional' plan (and higher plans):
160+
161+
```php
162+
<?php
163+
// This "if" block will be auto removed from the Free version.
164+
if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
165+
// ... logic related to Professional plan and higher plans ...
166+
}
167+
?>
168+
```
169+
170+
Add logic only for users in trial:
171+
172+
```php
173+
<?php
174+
if ( my_prefix_fs()->is_trial() ) {
175+
// ... logic for users in trial ...
176+
}
177+
?>
178+
```
179+
180+
Add logic for specified paid plan:
181+
182+
```php
183+
<?php
184+
// This "if" block will be auto removed from the Free version.
185+
if ( my_prefix_fs()->is__premium_only() ) {
186+
if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
187+
188+
// ... logic related to Professional plan only ...
189+
190+
} else if ( my_prefix_fs()->is_plan( 'business' ) ) {
191+
192+
// ... logic related to Business plan and higher plans ...
193+
194+
}
195+
}
196+
?>
197+
```
198+
199+
## Excluding files and folders from the free plugin version
200+
There are two ways to exclude files from your free version.
201+
202+
1. Add `__premium_only` just before the file extension. For example, functions__premium_only.php will be only included in the premium plugin version. This works for all type of files, not only PHP.
203+
2. Add `@fs_premium_only` a sepcial meta tag to the plugin's main PHP file header. Example:
204+
```php
205+
<?php
206+
/**
207+
* Plugin Name: My Very Awesome Plugin
208+
* Plugin URI: http://my-awesome-plugin.com
209+
* Description: Create and manage Awesomeness right in WordPress.
210+
* Version: 1.0.0
211+
* Author: Awesomattic
212+
* Author URI: http://my-awesome-plugin.com/me/
213+
* License: GPLv2
214+
* Text Domain: myplugin
215+
* Domain Path: /langs
216+
*
217+
* @fs_premium_only /lib/functions.php, /premium-files/
218+
*/
219+
220+
if ( ! defined( 'ABSPATH' ) ) {
221+
exit;
222+
}
223+
224+
// ... my code ...
225+
?>
226+
```
227+
The file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
228+
229+
# WordPress.org Compliance
230+
Based on [WordPress.org Guidelines](https://wordpress.org/plugins/about/guidelines/) you are not allowed to submit a plugin that has premium code in it:
231+
> All code hosted by WordPress.org servers must be free and fully-functional. If you want to sell advanced features for a plugin (such as a "pro" version), then you must sell and serve that code from your own site, we will not host it on our servers.
232+
233+
Therefore, if you want to deploy your free plugin's version to WordPress.org, make sure you wrap all your premium code with `if ( my_prefix_fs()->{{ method }}__premium_only() )` or the other methods provided to exclude premium features & files from the free version.
234+
235+
## Deployment
236+
Zip your plugin's root folder and upload it in the Deployment section in the *Freemius Developer's Dashboard*.
237+
The plugin will be scanned and processed by a custom developed *PHP Processor* which will auto-generate two versions of your plugin:
238+
239+
1. **Premium version**: Identical to your uploaded version, including all code (except your `secret_key`). Will be enabled for download ONLY for your paying or in trial customers.
240+
2. **Free version**: The code stripped from all your paid features (based on the logic added wrapped in `{ method }__premium_only()`).
241+
242+
The free version is the one that you should give your users to download. Therefore, download the free generated version and upload to your site. Or, if your plugin was WordPress.org complaint and you made sure to exclude all your premium code with the different provided techniques, you can deploy the downloaded free version to the .org repo.
243+
244+
## Reporting Bugs
245+
Email dev [at] freemius [dot] com
246+
247+
## FAQ
248+
249+
## Copyright
250+
Freemius, Inc.

vendor/freemius/assets/css/admin/account.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)